I'm trying to pass on a URL variable using Javascript and it works fine in Fire Fox but not in IE. I've been reading that IE7 has a problem with GetElementbyID but I don't know how to work around it using the code. Any help would be greatly appreciated.

<script type="application/javascript">

	function link ( ) {

			var urlout = "https://www.aarphealthcare.com/RequestInformation";

			var urlquery = location.href.split("?");

			var myNewVar = urlquery[1];

			if(myNewVar){
				urlout = "/Marketing/UHG/Landing/50to64/RequestInformation.aspx?"+myNewVar+"&products=EHI";
			}	 else {
			urlout = "/Marketing/UHG/Landing/50to64/RequestInformation.aspx?products=EHI";
			}

			document.getElementById('linkout').href=urlout;
			document.getElementById('linkout2').href=urlout;

	}	
		window.onload=function(){link()}
		</script>

Well i hope you have enabled scripting on your browser...

Simply add the following lines in your code...

//Additional lines starts here -->

if (document.all && !document.layers) {
document.all.linkout.href = urlout;
document.all.linkout2.href = urlout; } else {

//Preserved Lines -->

document.getElementById ('linkout').href = urlout; 
document.getElementById ('linkout2').href =urlout; }
} 

// Additional lines -->

if (window.addEventListener)
window.addEventListener('load',link,false);
else if (window.attachEvent)
window.attachEvent('onload',link);
else if (document.getElementById)
window.onload = link;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.