Forum Moderators: open
function jump(callsheet){
var currloc = window.location;
var findhash = currloc.substr( currloc.indexOf("#"));
if(findhash==-1){
var windowloc = window.location.split("#");
window.location = windowloc[0] + "#CS" + callsheet;
}else{
window.location = window.location+"#CS" + callsheet;
}
}
It basically checks to see if there is a hash in the url. If there is it splits it into an array. It then takes the part of the array which has everything before the hash and adds the anchor onto it.
If the url has no hash it just adds the anchor.
This where the function is called from:
<select name="callsheet" id="callsheet" class="form" onChange="jump(this.selectedIndex+1)">
<option value="1" id="1">1</option>
<option value="2" id="2">2</option>
</select>
function jump(callsheet) {
var currloc = window.location;
currloc = currloc.toString();
var findhash = currloc.substr( currloc.indexOf("#"));
if (findhash == -1) {
var windowloc = window.location.split("#");
window.location = windowloc[0] + "#CS" + callsheet;
} else {
window.location = window.location+"#CS" + callsheet;
}
}
Take a look here: [developer.mozilla.org...]