how to detect mraid support on device

835 views
Skip to first unread message

Generic Person

unread,
Sep 18, 2013, 8:50:48 PM9/18/13
to ormma-di...@googlegroups.com

Hi all,


Thanks for providing this platform to discuss MRAID issues.

My question is regarding detection of MRAID support from a creative developer's perspective.


Is there a way for me to detect if MRAID is supported on a device before serving the MRAID compatible ad on that device.

I understand that script reference to "mraid.js" would identify an ad as MRAID compliant, but what if the device does not support MRAID?


Thanks a bunch in advance.

Nathan Carver

unread,
Sep 19, 2013, 3:12:02 PM9/19/13
to ormma-di...@googlegroups.com
Hello,

Yes, two-way identification can be tricky. The SDK wants to know if it is an MRAID ad and the ad wants to know if it is an MRAID container.

To solve this chicken and the egg, MRAID puts the initiative on the ad designer. They must include "mraid.js" somehow. The path to mraid.js is purposefully relative, meaning that if the container is not MRAID, then the http request to mraid.js will fail silently and not impact the ad display.

Since you have identified your ad as MRAID by including the request for mraid.js, you can then check for the container by looking for the namespace variable "mraid". If this is null or undefined, then you are not in an MRAID container.

Does that help?

Thanks,
-Nathan



--
You received this message because you are subscribed to the Google Groups "ORMMA-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ormma-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Generic Person

unread,
Sep 19, 2013, 5:44:16 PM9/19/13
to ormma-di...@googlegroups.com
Thanks for the prompt reply Nathan, appreciate it , have a great day.

Generic Person

unread,
Oct 11, 2013, 2:05:03 PM10/11/13
to ormma-di...@googlegroups.com
Hi Nathan, Looking more into this,

(1) When my ad is served inside an IFrame, and I include <script src="mraid.js"></script> tag, 
      wouldn't it look for mraid.js on the ad server as opposed to mraid.js of device sdk?
      or is <script src="mraid.js"></script> a magic string which is intercepted and interpreted by device sdk to invoke mraid?


(2) I understand that after the creative has identified itself as mraid compliant, the SDK will load mraid javascript library and make mraid namespace available
     Is this understanding correct?
     if yes, Is there any event that the creative can listen to, to ensure that SDK has loaded mraid.js into the container before it checks for mraid namespace?
     My concern is that what if the creative checks for mraid namespace before the SDK had time to load mraid.js.

Thanks again in advance.

Nathan Carver

unread,
Oct 11, 2013, 2:18:14 PM10/11/13
to ormma-di...@googlegroups.com
Hi,

The role of the SDK is to listen-in on all network requests. When it sees a request for mraid.js, it intercepts the request so nothing is sent to a server. (If there's a failure, or the ad is delivered to web, the path is relative and will fail silently.) 

To clarify, <script scr="mraid.js"></script> is not a magic string. It's the request for "mraid.js" that the SDK should look for. It might come from statements like scr=document.createElement("script");scr.source = "mraid.js".

As for the creative, you are right that it is up to the SDK to provide the mraid namespace.

You can check in a number of ways. If you are able to listen for the mraid.ready event, then that signals the SDK has prepared everything. However, sometimes the ready event fires before you have a chance to register a listener. So you could simply check to see that the mraid object is available (not null) and check to see if the state is default. I think there's some sample code in the specification as well.

Thanks,
-Nathan

Reply all
Reply to author
Forward
0 new messages