nadafinga
10-04-2008, 12:25 AM
I'm having trouble getting this to work, any help would be appreciated. I'm basically trying to load a different css based on the current URL of the page. I've got that working and returning a short string to identify pages correctly, but after that, I can't get the javascript if/else statement to actually change what stylesheet is loaded. I've used alert boxes to make sure the variables are carrying through and they are. I'm sure it's obvious, but I can't seem to figure it out...
<head>
<link rel="STYLESHEET" id="topNavSwitch" href="~/kitchenstopnav.css" type="text/css" />
<script type="text/javascript">
var url=window.location.pathname.substr(1, 4);
//alert(url);
var link = document.getElementsByTagName("link")[1].href;
var newLink01 = "www.kitchens.com/kitchenstopnav01.css";
var newLink02 = "www.kitchens.com/kitchenstopnav02.css";
if(url == "exam"||"/exa"){
link = newLink01;
}else if(url =="desi"||"/des"){
link = newLink02;
}else{
link = link;
}
</script>
</head>
<head>
<link rel="STYLESHEET" id="topNavSwitch" href="~/kitchenstopnav.css" type="text/css" />
<script type="text/javascript">
var url=window.location.pathname.substr(1, 4);
//alert(url);
var link = document.getElementsByTagName("link")[1].href;
var newLink01 = "www.kitchens.com/kitchenstopnav01.css";
var newLink02 = "www.kitchens.com/kitchenstopnav02.css";
if(url == "exam"||"/exa"){
link = newLink01;
}else if(url =="desi"||"/des"){
link = newLink02;
}else{
link = link;
}
</script>
</head>