473,969 Members | 2,340 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
getElementsByTa gName("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 getElementsByTa gName("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="gosomepla ce"> click
this link</a> .
Jul 20 '05 #1
4 56694
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 disableOtherLin ks(URL){
globalHtml="<ht ml><body>Please Wait<script type=\"text/javascript\">"
+"location=\""+ URL+"\";<\/script></body></html>";
location="javas cript:window.gl obalHtml";
}
</script>
</head>
<body>
<a href="http://www.google.com"
onclick="disabl eOtherLinks('ht tp://www.google.com' );return false">Google</a>
<a href="http://www.yahoo.com"
onclick="disabl eOtherLinks('ht tp://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.getEle mentsByTagName( "a");

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

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

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

document.getEle mentsByTagName( "a")[i].style.cursor=w ait';// 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.c om...
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 disableOtherLin ks(URL){
globalHtml="<ht ml><body>Please Wait<script type=\"text/javascript\">"
+"location=\""+ URL+"\";<\/script></body></html>";
location="javas cript:window.gl obalHtml";
}
</script>
</head>
<body>
<a href="http://www.google.com"
onclick="disabl eOtherLinks('ht tp://www.google.com' );return

false">Google</a> <a href="http://www.yahoo.com"
onclick="disabl eOtherLinks('ht tp://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)
addEventListene r / removeEventList ener 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******** ***********@new s4.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 getElementsByTa gName("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 getElementsByTa gName("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="gosomepla ce"> 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 misunderstandin g 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
81569
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
2635
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 in the row... if i however have some text in the row that has an href link attached to it, when i click on the link it will go to the href url AND open the popup window...
6
3184
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 href="#">bahbahbah</a> Does not work, as it is still clickable. It only changes the color to grey.
4
26665
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, Jamie
16
4470
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 href="lemurs.html">Lemurs</a></li> <li><a href="chameleons.html">Chameleons</a></li> </ul> <ul>
1
5547
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 would be great , if i know how to create the dynamic HREF links like it should be getting different document based on each userid. Here is my part of jsp code for your reference: <%@ page...
0
2406
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 he had placed will be displayed in a DataList. Also assume that the OrderID of the last order is 13. The details of the earlier orders placed by a particular user (when the user places more than 1 order) can be viewed by clicking links. The...
3
2949
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 condain 4 link (<a href...>page1.aspx</a <br <a href ....>page2</aetc..). that will redirect another page ex:(page1.aspx).
1
1514
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 not 18 or over)" and this resolves in window.close, example: <html> <body>
0
10338
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10149
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11541
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10056
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
5136
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.