SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Aug 27, 2003, 02:34 #1
- Join Date
- Feb 2002
- Posts
- 127
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to disable an 'href' link using JS?
Hi All
I am making a page that uses JS to bring up a "popup <div>" when the user clicks on a particular link. I am concerned that if the users browser has JS turned off, nothing will happen when they click. I thought the way around this would be to have a valid href in the link so that if the JS doesn't work, the browser will be directed to an alternative page.
Can I include something in my JS function so that when the user clicks the link, the JS will run and disable the href link at the same time? My thinking is, if JS is disable in the browser, this function would not work, so the browser would continue to load the href link.
Regards, benExperience is that thing which lets you know you've made the same mistake yet again.
-
Aug 27, 2003, 03:05 #2
- Join Date
- Aug 2003
- Location
- Netherlands
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
onclick="yourfunction();return false;"
-
Aug 27, 2003, 03:09 #3
- Join Date
- Jul 2003
- Location
- Moncton, New Brunswick, Canada
- Posts
- 247
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
You can use the same technique as if you were doing an accessible popup, but instead of calling a new window just call the function that opens the div instead:
Code:<a href="alternative_url.htm" onclick="openDiv(); return false;">pop me</a>
-xDev
-
Aug 27, 2003, 23:39 #4
- Join Date
- Feb 2002
- Posts
- 127
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks, that was just what I needed.
Experience is that thing which lets you know you've made the same mistake yet again.
Bookmarks