admin管理员组文章数量:1334199
I've been trying to create an mraid pliant ad, but haven't gotten very far. According to the official documentation, which can be found at this link, the addition of a simple
<script src='mraid.js'></script>
should be sufficient. This, however, doesn't seem to be the case. I copied the following example code to test the existence of the mraid object, but it just stays undefined. The precise FireBug error is:
ReferenceError: mraid is not defined
I'm trying to execute the following (very simple) code:
if(mraid.getState() !='ready'){
console.log("MRAID NOT READY");}
Does anyone have any experience with this problem?
I've been trying to create an mraid pliant ad, but haven't gotten very far. According to the official documentation, which can be found at this link, the addition of a simple
<script src='mraid.js'></script>
should be sufficient. This, however, doesn't seem to be the case. I copied the following example code to test the existence of the mraid object, but it just stays undefined. The precise FireBug error is:
ReferenceError: mraid is not defined
I'm trying to execute the following (very simple) code:
if(mraid.getState() !='ready'){
console.log("MRAID NOT READY");}
Does anyone have any experience with this problem?
Share Improve this question edited Dec 2, 2015 at 14:14 vard 4,1562 gold badges29 silver badges49 bronze badges asked Mar 15, 2013 at 12:17 danvdendedanvdende 2451 gold badge6 silver badges15 bronze badges 2- 1 Your code is wrong, you expect mraig.getState to return 'ready', but this state do not exist. It's a mon error on many MRAID sample codes, indeed when mraid is ready, the mraid.getState return 'default'. – kketch Commented Mar 25, 2013 at 15:03
- Thanks for your ment! :) It isn't the problem here, as John Cappiello mentioned already, but could definitely have been a problem later on :) – danvdende Commented Mar 26, 2013 at 11:10
1 Answer
Reset to default 6Yes, it's not quite as simple as that, and the spec isn't entirely clear.
mraid.js is injected by whatever ad platform your being flighted from.
It looks something like this:
App -> Ad SDK -> MRAID Ad
The Ad SDK instantiates a UIWebView and injects mraid.js to be available. Then your script tag above finds it, loads it, and everything else resolves itself from there.
Your options are either:
- make your own mraid.js for testing purposes that has enough of the spec to be handy /testing
- spin up a mobile ad server SDK that does the above for you, and then just test against that
- checkout http://webtester.mraid which will let you avoid some of the above
2 is the most precise. 1 & 3 get you far, but nothing pares to the real thing in app with an actual ad server's sdk handling things.
本文标签: javascriptmraid undefinedStack Overflow
版权声明:本文标题:javascript - mraid undefined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742334752a2455401.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论