473,408 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

disable all href/links when user click a link

KS
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> .
Jul 20 '05 #1
4 56634
Lee
KS said:
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.


One approach would to ensure that clicking any link immediately loads
an intermediate page that doesn't have anything to click on.

Here's an example that builds that intermediate page on the fly.
This has the side-effect of not allowing some browsers to go BACK
to the page with the links:
<html>
<head>
<script type="text/javascript">
function disableOtherLinks(URL){
globalHtml="<html><body>Please Wait<script type=\"text/javascript\">"
+"location=\""+URL+"\";<\/script></body></html>";
location="javascript:window.globalHtml";
}
</script>
</head>
<body>
<a href="http://www.google.com"
onclick="disableOtherLinks('http://www.google.com');return false">Google</a>
<a href="http://www.yahoo.com"
onclick="disableOtherLinks('http://www.yahoo.com');return false">Yahoo</a>
</body>
</html>

Jul 20 '05 #2
KS
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.
If youre solution could write out the text but without the href on it i
would be pleased.
Something like this before onclick:

www.google.com
www.onjava.com
www.javascript.com

and after click , just as above, but then as plain text as if the text was
writen between <td> ...</td> but without the <a href"blabla"> </a>
This javascript does the job, but stop the request which is made when i
click on the link the first time. I would be using onclick to call the
javascript.

function disablehref(){

var input = document.getElementsByTagName("a");

var count = input.length;
for(var i =0; i < count; i++){

document.getElementsByTagName("a")[i].disabled = true;// Does not disable
the link it just gives it a grey color, but works with buttons

document.getElementsByTagName("a")[i].removeAttribute("href"); //OBS this
works but also stops the request and the next page does not get loaded, just
hangs in the first page

document.getElementsByTagName("a")[i].style.cursor=wait';// just to give the
mousepointer the wait symbol instead of the hand

}
return true;
}


"Lee" <RE**************@cox.net> wrote in message
news:bl*********@drn.newsguy.com...
KS said:
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 anyafter the first time.
One approach would to ensure that clicking any link immediately loads
an intermediate page that doesn't have anything to click on.

Here's an example that builds that intermediate page on the fly.
This has the side-effect of not allowing some browsers to go BACK
to the page with the links:
<html>
<head>
<script type="text/javascript">
function disableOtherLinks(URL){
globalHtml="<html><body>Please Wait<script type=\"text/javascript\">"
+"location=\""+URL+"\";<\/script></body></html>";
location="javascript:window.globalHtml";
}
</script>
</head>
<body>
<a href="http://www.google.com"
onclick="disableOtherLinks('http://www.google.com');return

false">Google</a> <a href="http://www.yahoo.com"
onclick="disableOtherLinks('http://www.yahoo.com');return false">Yahoo</a> </body>
</html>

Jul 20 '05 #3
VK
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 <no****@hotmail.com> wrote in message
news:mI*******************@news4.e.nsc.no...
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> .

Jul 20 '05 #4
Lee
KS said:

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.

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: Mark Johnson | last post by:
You have an, a, anchor with href link. Can you use a stylesheet to effectively disable the link, so that you can't click on it; that it will appear simply as text?
1
by: SomeGei | last post by:
Hey guys.... i have a really big table... and the <tr> tags have onclick/onmouseover events that highlight a row when you drag your mouse over it, and open a popup window when you click anywhere...
6
by: nntp | last post by:
I have a set of links which I want search engines to crawl them, but I want to disable them from my visitors, so I will ask the link owners to pay me to let me enable them. <a disabled...
4
by: Jamie Jackson | last post by:
I know that it's possible to return false in an onClick to disable a link. Is there a way to do this within the HREF attribute? Something like: <a href="javascript: return false;"> ? Thanks,...
16
by: michael | last post by:
Is it possible to get all href URLs contained in a unordered list and place them in an array? Or in fact two different arrays, differently named one for each <ul> group? <ul> <li><a...
1
by: nsvmani | last post by:
Hi, i am trying to get the FileOpen dialogue window as soon as clicked href link I am using IE6 with ActiveX enabled. Just need to get the File Open dialogue window when i click on the HREF links.It...
0
by: rn5a | last post by:
In a shopping cart app, assume that a user has placed 4 orders (each order has a corresponding OrderID which will be unique). When he comes to MyCart.aspx, by default, the details of his last order...
3
by: ajaspersonal | last post by:
"i want to change font_style (hyper link<a href...>text</a>) normal to italics.when load a page" this is my problem but that label included in one 'USERCONTROL' This user controls may...
1
by: wolf18 | last post by:
I am running a business and I have a forum on it but I do not want under 18's to access it due to that its for booking and to hire, anyway what ive done is ive created a link that says "Leave (Iam...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.