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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Load A URL - Javascript Help Please

    Hi Guys,

    A client has given me some code but i need to add some code to it so it loads a URL along with the rest of the code. Below is the javascript code i need to work with, i know its to do with Google Tracking (Dart) but i dont understand it as I've never done JavaScript before:

    Code:
    <script type="text/javascript">
    function dart_tracking(callback) {
    
    // Google Conversion Tracking
    var img = new Image();
    img.src="
    https://www.googleadservices.com/pagead/conversion/REMOVED/?value=0&label=REMOVED&guid=ON&script=0
    ";
    
    var img2 = new Image();
    img2.src="
    https://www.googleadservices.com/pagead/conversion/REMOVED/?value=0&label=REMOVED&guid=ON&script=0
    ";
    
    _gaq.push(['_trackEvent', 'subscribeButton', 'clicked']);
    
    if (typeof callback != "undefined") {
    setTimeout(callback, 1500);
    }
    }
    </script>
    Now the above code loads up when a subscribe button is clicked on my clients webpage, now how do i go about adding code to this so lets say http://www.Google.co.uk is loaded too?

    Any help would be great.

    Thank you!

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,969
    Thanks
    56
    Thanked 557 Times in 554 Posts
    you want a page with google (let's say) on it to open when you click the button?

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xelawho View Post
    you want a page with google (let's say) on it to open when you click the button?
    Yea, but i cant do the OnClick thing as the button already has that which calls the code above in my first post. I dont want the page to open in a new tab/window i just want the site to load that i want. So hows the best way of doing this?

    Iframe width 0 and height 0 or is there a way of loading a webpage in javascript but hidden?

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,969
    Thanks
    56
    Thanked 557 Times in 554 Posts
    Quote Originally Posted by adwarm View Post
    Iframe width 0 and height 0 or is there a way of loading a webpage in javascript but hidden?
    this is sounding dodgier and dodgier as we go along.

    why can't the button have multiple onclick events?

    Code:
    <input type="button" value="click me!" onclick="function1(); function2()"/>
    afaik, any time you load a new window (whether you can see it or not) the user is alerted, at least by any browser made in the last 10 years or so, but I might be wrong on that.

  • #5
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xelawho View Post
    this is sounding dodgier and dodgier as we go along.

    why can't the button have multiple onclick events?

    Code:
    <input type="button" value="click me!" onclick="function1(); function2()"/>
    afaik, any time you load a new window (whether you can see it or not) the user is alerted, at least by any browser made in the last 10 years or so, but I might be wrong on that.
    Hi,

    Hehe let me assure you theres nothing dodgy about what where doing, the URL that will be loading will be our tracking url which will track signup conversions etc.. I guess we can do it as 2 onclick events, i just didnt know this was possible as like i said I've never worked with Javascript before. Thanks for your comment How do i go about loading a URL in the background (loads our conversion tracking url) when a button is clicked?

    EDIT: just read your comment again, so if it alerts them then it is best to do it from an iframe? If so how do i go about doing this?

    Thanks

  • #6
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,969
    Thanks
    56
    Thanked 557 Times in 554 Posts
    you can compare the approaches for yourself:

    Code:
    <html>
    <head>
    </head>
    <body>
    
    <input type="button" value="open new window" onclick="openWin()">
    <input type="button" value="open iframe" onclick="openFrame()">
    <script>
    
    function openWin(){
    window.open("http://www.Google.co.uk")
    }
    
    function openFrame(){
    ifrm = document.createElement("IFRAME");
       ifrm.src= "http://www.yahoo.com/";
       ifrm.style.width = 0+"px";
       ifrm.style.height = 0+"px";
       ifrm.frameBorder=0;
       document.body.appendChild(ifrm); 
     }  
    </script>
    </body>
    </html>


  •  

    Posting Permissions

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