tfeuerst Posted January 14, 2016 Report Share Posted January 14, 2016 Hi all,I'm trying to display a zone within a responsive Webpage only on a certain minimum width.With the synchronous JavaScript code I did the following:<script type='text/javascript'> var width = window.innerWidth || document.documentElement.clientWidth; if (width >= 1050) { var m3_u = (location.protocol=='https:'?'https://.../live/www/delivery/ajs.php':'http://.../live/www/delivery/ajs.php'); var m3_r = Math.floor(Math.random()*99999999999); if (!document.MAX_used) document.MAX_used = ','; ... and so on ... } </script>Now I want to do same thing with the acynchronous code. But the following won't do, because of script tag within script tag.<script type='text/javascript'> var width = window.innerWidth || document.documentElement.clientWidth; if (width >= 1050) { <ins data-revive-zoneid="1" data-revive-id="f2a4f2a33e1fd01dd1a2a1bf15f09405"></ins> <script async src="//.../live/www/delivery/asyncjs.php"></script> } </script>To use document.write feels wrong, because I loose the advantage of the acynchronous code.<script type='text/javascript'> var width = window.innerWidth || document.documentElement.clientWidth; if (width >= 1050) { document.write ("<ins data-revive-zoneid='1' data-revive-id='f2a4f2a33e1f465462a1bf15f09405'></ins>"); document.write ("<scr"+"ipt async src='//.../live/www/delivery/asyncjs.php'"); document.write ("><\/scr"+"ipt>"); } </script>Does anybody have a solution for that?Thanks in advance. Quote Link to comment Share on other sites More sharing options...
tfeuerst Posted January 21, 2016 Author Report Share Posted January 21, 2016 Has nobody an idea?Is it more a javascript issue and better to ask in a JS community? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.