...

View Full Version : checking url



theste
01-30-2007, 10:29 AM
heya, Ok, im trying to check the url using java script

essentially this is what i would like to do

if url1 = current_url {
import script 1
} else
if url1 = current_url {
import script 2
} else
if url1 = current_url {
import script 3
}

any help, suggestions would be ideal, thankyou

i should also point out that im not the most compitant programmer, nor do i know java script ><

chump2877
01-30-2007, 11:11 AM
I think you want something like this:


<script type="text/javascript">

if (url1 == window.location.href)
addJavascript(scriptName1);
else if (url2 == window.location.href)
addJavascript(scriptName2);
else if (url3 == window.location.href)
addJavascript(scriptName3);


function addJavascript(jsname)
{
var th = document.getElementsByTagName('head')[0];
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src',jsname);
th.appendChild(s);
}

</script>

theste
01-30-2007, 12:08 PM
thanks mate, appreciated :) a littel fiddling around and its all working :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum