I am trying to change the background color of a div to show which page page is currently being used and I can't get it to work, I've Googled loads of stuff but everything I've tried doesn't work so here it is:
<script type="text/javascript" language="javascript">
//get the page URL and take the substring after the ?
qsFull = window.location.search.substring(1);
//split the substring based on the location of the =
qsValue = qsFull.split("=");
//check on the value of querystring parameter and write the appropriate headline
if(qsValue[1] == "no")
{
document.writeln('<h1>Div1<\/h1>');
document.getElementById('div1').style.backgroundColor = '#D4DBE7';
}
else
{
document.writeln('<h1>Div2<\/h1>');
document.getElementById('div2').style.backgroundColor = '#D4DBE7';
}
</script>
<style>
.class1 {
display: block;
border: 1px solid #D4DBE7;
width: 100px;
height: 25px;
margin: 5px 0;
line-height: 25px;
text-align: center;
text-decoration: none;
}
#div1 {
float: left;
background-color: #FFF;
}
#div2 {
float: right;
background-color: #FFF;
}
</style>
<div style="width: 240px; height: 25px;">
<label>Choose Online or Offline</label>
<a href="/EN/test/test.asp?offline=no" id="div1" class="class1">Online</a>
<a href="/EN/test/test.asp?offline=yes" id="div2" class="class1">Offline</a>
</div>
<div style="clear: both; height: 0;"></div>Thanks in advance for any help
Ian

New Topic/Question
Reply



MultiQuote




|