HighDots Forums  

disable all href/links when user click a link

Javascript JavaScript language (comp.lang.javascript)


Discuss disable all href/links when user click a link in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
KS
 
Posts: n/a

Default disable all href/links when user click a link - 09-26-2003 , 02:40 PM






Im trying to prevent the user from clicking any other links on my page when
the user have selected/clicked a href once.
Sometimes it takes a while before the next page loads so some user will try
clicking other links or the same link.
I can prevent this when i use buttons by calling onclick and in a javascript
getElementsByTagName("input") and then check the type to be type of "button"
or "submit" which i then disable. It works.
This also works for href html tags by calling onclick and in a javascript
remove all href, BUT it also stops everything, even the request that is
about to happen.
If i use disable getElementsByTagName("a") on href like with buttons it does
not get unclickable just get a grey color but you can click on it.

Any workaround to this? This is a seriuos web app so I want the solution
where i disable ALL links on my page so it is not possible to click on any
after the first time.
All the links is NOT in a form only links using <a href="gosomeplace"> click
this link</a> .



Reply With Quote
  #2  
Old   
VK
 
Posts: n/a

Default Re: disable all href/links when user click a link - 09-26-2003 , 04:51 PM






1st solution is to work via

attachEvent / detachEvent with cancelBubble (Explorer)
addEventListener / removeEventListener with useCapture (Netscape)

"a seriuos web app" - so let it be a serious solution :-)

But I would propose much easier 2nd solution. Just make a top level event
listener (window or document) and a hidden div at the bottom of the page

If this listener gets onclick event and its source is a link, it resizes the
div to the size of the screen and makes it visible with some good z-index
(1000 would go for all situations). So effectively you cover all screen with
a transparent glass - you can see, but you cannot touch.
If you also make this div to respond on click events (say show an alert
"Your request is processing, please don't ruch us!" - that would be
totally super.

KS <nospam (AT) hotmail (DOT) com> wrote

Quote:
Im trying to prevent the user from clicking any other links on my page
when
the user have selected/clicked a href once.
Sometimes it takes a while before the next page loads so some user will
try
clicking other links or the same link.
I can prevent this when i use buttons by calling onclick and in a
javascript
getElementsByTagName("input") and then check the type to be type of
"button"
or "submit" which i then disable. It works.
This also works for href html tags by calling onclick and in a
javascript
remove all href, BUT it also stops everything, even the request that is
about to happen.
If i use disable getElementsByTagName("a") on href like with buttons it
does
not get unclickable just get a grey color but you can click on it.

Any workaround to this? This is a seriuos web app so I want the solution
where i disable ALL links on my page so it is not possible to click on any
after the first time.
All the links is NOT in a form only links using <a href="gosomeplace"
click
this link</a> .





Reply With Quote
  #3  
Old   
Lee
 
Posts: n/a

Default Re: disable all href/links when user click a link - 09-26-2003 , 06:07 PM



KS said:
Quote:
Good idea if I wanted to display the message over the hole page, but I think
it is a bit extreme and will be the last choice if nothing else solves this
problem. There must be someway to disable everything without changing the
look of the page.
Maybe I'm misunderstanding the situation.
Once the person has clicked on a link, why do they care
if the look of the page changes?
If your page takes long enough to load that they would
get bored looking at a "Please wait" sort of message,
maybe you should be concentrating on speeding up the response.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.