...

View Full Version : Load A URL - Javascript Help Please



adwarm
12-30-2011, 10:25 PM
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:



<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!

xelawho
12-30-2011, 10:43 PM
you want a page with google (let's say) on it to open when you click the button?

adwarm
12-31-2011, 12:12 AM
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?

xelawho
12-31-2011, 01:16 AM
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?



<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.

adwarm
12-31-2011, 01:50 AM
this is sounding dodgier and dodgier as we go along.

why can't the button have multiple onclick events?



<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

xelawho
12-31-2011, 03:19 AM
you can compare the approaches for yourself:



<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum