Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Loading ads dynamically

    hello,

    I'm trying to load the ads on my site dynamically and have ran into an issue and was hoping for some help.

    First - I can get the ads to load using vanilla javascript with the code below.

    Code:
        var ifrm = document.createElement("iframe");
        ifrm.setAttribute("src", OAS_url + "adstream_sx.ads/" +sitePage + "/" + uniqid() + "@" + pos);
        var ifrmId = "ifrm_" + uniqid();
        ifrm.setAttribute("id", ifrmId);
        ifrm.setAttribute("marginwidth", 0);
        ifrm.setAttribute("marginheight", 0);
        ifrm.setAttribute("frameborder", 0);
        ifrm.setAttribute("scrolling", 0);
        ifrm.setAttribute("height", container.scrollHeight + (container.offsetHeight - container.clientHeight));
        ifrm.setAttribute("width", container.scrollWidth + (container.offsetWidth - container.clientWidth));
      
    
        container.appendChild(ifrm);

    But since the site is using jquery I wanted to develop it out that way. So I have the following code,

    Code:
    iRandom = oas.uniqid();
    sAdURL = opt.url + 'adstream_mjx.ads/' + opt.sitepage + '/1' + iRandom + '@' + sPos + '?' + opt.query;
    
    						
    $('<iframe />', {
      src: sAdURL,
      id:   sPos
    }).appendTo(thisAd);
    I figured the reason this isn't working is the difference between appendChild and appendTo and the fact that things are jquery objects.

    So again the top code block renders the ads and the lower code block just shows the javascript code from the ad provider. Any help to get this to work in jquery would be grateful.

    Thanks

  • #2
    New to the CF scene
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yeah i get that its an abstraction of js. After looking into the issue more its because the returned code from the ad service is using document.write.

    I can't change the output form them, but I have been trying to find a way to get the ads to load on dom ready. I was thing of overwriting the document.write function but I'm not sure on the correct way to do this.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •