javascript - Iframe src depending device width -
I am doing a web page, and I have ads in it.
I am advertising with Google Web Designer, this program generates an iframe
In the work of the client device, especially the width of this device, I show a specific iframe I like. Can I specify the source of the iframe which I want to show in device-width work?
I try to use the media queries in CSS to hide all iframes except the correct, but this is not working correctly; I try it on Windows Phone and Android.
Offopaxic: If someone knows better software than Google Web Designer, then let me know.
You can use jQuery, say that the id in your iframe is "frame"
& lt; Script type = "text / javascript" src = "http: //ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> & Lt; Script & gt; Var width = (window.innerWidth> 0)? Window.innerWidth: screen.width; If (width == 950) $ ('# frames'). Attr ('src', url); And if (width == 750) $ ('# frames'). Att ('src', url2); ... ... ... & lt; / Script & gt;
Comments
Post a Comment