Jump to content

Recommended Posts

Posted

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.

 

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...