Detect if client changes URL

E

eggie5

On my page I have links like this:

<a href="#files/home.html"><img id="home" src="images/home.png"
alt="Home" width="36" height="10" /></a>

which will append "#files/home.html" to the URL in the browser. I need
to figure out how to detect this event.

How can I detect if the client clicks on a link like <a
href="#files/home.html">?
 
T

Tom Cole

On my page I have links like this:

<a href="#files/home.html"><img id="home" src="images/home.png"
alt="Home" width="36" height="10" /></a>

which will append "#files/home.html" to the URL in the browser. I need
to figure out how to detect this event.

How can I detect if the client clicks on a link like <a
href="#files/home.html">?

You can generically add an onunload event handler to the page.

If you need to know about each link you can add on onclick event
handler to the anchors.
 
O

One Dumm Hikk

On my page I have links like this:

<a href="#files/home.html"><img id="home" src="images/home.png"
alt="Home" width="36" height="10" /></a>

which will append "#files/home.html" to the URL in the browser. I need
to figure out how to detect this event.

How can I detect if the client clicks on a link like <a
href="#files/home.html">?

Onload of the page, you check the Hash property.

window.onload = checkIt
function checkIt(){
//check the URL of the current page
}

Now, open your page, click one of your links, then click another one.
Unless you are careful and watch for it, you will end up with a
malformed URL that has two #'s in it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top