Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

attach to query string

Status
Not open for further replies.

topcat1a

Programmer
Jan 6, 2005
34
GB
Hello,

When a user clicks away from the page (There are multiple ways of doing this) I need to attach the title (of the current page) to the end of the query string.

Anyone know how to do this?
 
This would work... also... when you said clicked away i assume you mean a link... because i dont think u could do it with a back button click...


Code:
<head>
<title>This is a test</title>

<script type="text/javascript">
function doLinkTitle() {
  document.getElementById('link1').href="/default.asp?title=" + document.title;
}
</script>

</head>

<body onload="doLinkTitle();">
<a href="" id="link1">Link</a>
</body>
</html>

Army : Combat Engineer : 21B

 
Thanks for the help.

Does anyone know if I can find out if the user clicks the back button of their browser? Or in that case the forwards button?
 
there is no way to change the history, which is, in essence, what you want to do.

best you can do is loop through each link in the page and add the current page to each:

Code:
function doThing() {
    var a = document.getElementsByTagName("a");
    for ( var i = 0; i < a.length; i++ ) {
        a.href += "?ref=" + window.location;
    }
}



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top