disable link that call to js function

Posted on 2007-03-25
Last Modified: 2008-02-01
I have links that call to JS function (<a href="javascript:runproc(window.document.mform)">).
I want to disable double clicking case.
i cant change the link but i can change the function (runproc).

there is a way to disable the link from the script? (using this.disable or something like that?)
i remind, i can't add id or something else to the href.. only change the script.

Thanks Ahead,
Question by:omribi
  • 3
  • 2
  • 2
  • +1

Expert Comment

ID: 18788853
Not sure I quite understood your question, but here's my best shot:

To disable double click you need:

ondblclick = return false

To disable a link you can try out these:

Hope that helps.

Author Comment

ID: 18789190
What i mean is :
i dont have access to the dll that create the link.
i've access to the external JS that the link run.
i want to disable double click but i cant add anything to the link itself, only to the function it run.

i've added flag to the function, when it run first time it set it to true and then block 2nd time running.
but the problem is, when you press on the link 2nd time it stop the first submit...
so i want to disable the link so it won't stop the 1st submit.


Expert Comment

ID: 18789263
Ok, try putting this at the end of the function:

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

LVL 63

Expert Comment

ID: 18789701
The problem is that scripts started from href do NOT have a reference to the <a> tag. The reference to the anchor tag do scripts get only from event handler like onClick. There you can use that "this" reference.
But if the anchor with the function runproc() is called only once on the page, or the anchor can be identified by a name or else, then I would have a trick for you.


Author Comment

ID: 18803232
this.disabled - is not working, i can click on the link twice (the 2nd click disable the 1st action).
the JS function submit the form after validation, so the 2nd click stop the 1st submit and resubmit it.

I have title for this tag only.. i dont have name/id.


Expert Comment

ID: 18816644
Make a function that is called on loading the body to insert an onclick in the <a> tag. Make the onclick="return false;" and the user wil not jump when they click on the link.

Accepted Solution

Cyber-Drugs earned 250 total points
ID: 18816818

"i dont have access to the dll that create the link."

Unfortunately he can't follow your solution either, to be honest, I don't think this is possible without being able to edit the actual HTML code...
LVL 63

Assisted Solution

Zvonko earned 250 total points
ID: 18817021
You have no access to "this" because your script is called from href string and not from the link onClick event handler.
Can you change the call to this:

<a href="#" onClick="runproc(window.document.mform,this)">bla bla</a>


Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now