What I need to do:
1. Need catch all onclick events in both IE and NS (currently dealing with IE browsers only)
2. Add some extra params to the URL that is going to be loaded
But I can not assign event handle via html, i.e
<a href=http://www.webdeveloper.com/forum/archive/index.php/"...." onClick="doThis();">link1</a>
So for IE browsers I have tried the following js code:
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE6 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;
function AssignONCLICK() {
if ((isIE4) || (isIE6)) {
if (document.links) {
for (var d=0; d < document.links.length; d++) {
document.links[d].onclick=AddParam;
}
}
}
}
function AddParam() {
if ((isIE4) || (isIE6)) {
alert("AddParam called"); //this alert box appears fine!
var sHref = this.href + "~" + document.SingleCat.value + "~L=AD";
alert(this.href + "~" + document.SingleCat.value + "~L=AD");
window.location = sHref; //but the window still loads with the original URL (as difined in html anchor tag).
}
}
So the above code seems like it has catched the onClick event.
But how can I how can add extra params to the current URL and load it?
I presume that I sill have to cancle the onclick event first and then do the window.location=URL bit, but how can I cancle it?
Also from checking the props of this in function AddParam, it looks like a link obj rather than a event obj that I need, any ideas?
Many thanks in adv
ivy
1. Need catch all onclick events in both IE and NS (currently dealing with IE browsers only)
2. Add some extra params to the URL that is going to be loaded
But I can not assign event handle via html, i.e
<a href=http://www.webdeveloper.com/forum/archive/index.php/"...." onClick="doThis();">link1</a>
So for IE browsers I have tried the following js code:
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE6 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;
function AssignONCLICK() {
if ((isIE4) || (isIE6)) {
if (document.links) {
for (var d=0; d < document.links.length; d++) {
document.links[d].onclick=AddParam;
}
}
}
}
function AddParam() {
if ((isIE4) || (isIE6)) {
alert("AddParam called"); //this alert box appears fine!
var sHref = this.href + "~" + document.SingleCat.value + "~L=AD";
alert(this.href + "~" + document.SingleCat.value + "~L=AD");
window.location = sHref; //but the window still loads with the original URL (as difined in html anchor tag).
}
}
So the above code seems like it has catched the onClick event.
But how can I how can add extra params to the current URL and load it?
I presume that I sill have to cancle the onclick event first and then do the window.location=URL bit, but how can I cancle it?
Also from checking the props of this in function AddParam, it looks like a link obj rather than a event obj that I need, any ideas?
Many thanks in adv
ivy