I have a problem and i need some help please. I have this page with a parameter http://www.webxpress.com/landingpage.asp?label=CSU...
Now in this page i have 3 buttons with the following links: www.webxpress.com/button1.asp www.webxpress.com/button2.asp www.webxpress.com/button3.aspAll i want is to add the parameter in the button links (depending on t开发者_开发技巧he parameter in the url)... For example: from www.webxpress.com/button1.asp the link comes www.webxpress.com/button1.asp?label=CSU (this parameter is taken from the url).
Can someone please help me and give me some tips because i do not know from where i should start.
You can use:
document.location.search
which returns the part of the URL after the ? sign (including the question-mark).
To test that this is what you want, try to navigate with your browser on a page with such parameters, and then type in the address bar of the browser:
javascript:alert(document.location.search)
Then, you can use document.write to write the links with this value at the end:
document.write("<a href='http://.../button1.asp" + document.location.search + "'>button1 link</a>");
You can use document.location.search
as the previous comment suggested and extract the part you are interested in. Afterwards you can iterate over every link in the page with document.links
and update them.
For example:
dl = document.links;
for(i = 0, len = dl.length; i < len; i++) {
dl[i].href = dl[i].href + '&label=CSU";
}
精彩评论