Select Categories Below
Advertisement
Start Your Own Q&A Site
Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.
Status: Closed Points: 125 Time: 05:47 - Jul 09, 2007
dustPuppy
I need to simulate a click on an anchor link through javascript. But it only works in IE 7, not in FF 2. Basically I need to capture an Enter-click on a textbox and call the right button to execute afterwards. I've added the following to the onkeydown attribute on the textfield: if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('searchButton').click();return false;}} else {return true}; " The "searchButton" is an html anchor (<a href=...>) and in IE7 the "click" is performed without problems. In firefox it says that ....click is not a function. So I'm a bit confused here. Anybody know what is the problem?
Categories:
Add Categories
When adding more than one category, separate them with commas.
jgivoni
Date:: Aug 07, 2007
Time:: 13:53
Good question. I thought it was simple but after testing and searching it seems it is not possible to do this in a simple way. First I thought - why not just fire the onclick instead of click? But onclick is not a function either until it has been written explicitly in the html. So what about setting onclick="return true"? This would normally activate the hyperlink (whereas onclick="return false" would disable it...) But it still doesn't do anything in Firefox. Running out of ideas, the 'best' thing could be to add this to the A element: <a href="..." onclick="location.href=this.href"> and then firing the onclick event instead of click(). Problems with this method: 1. It wont work If the href starts with "javascript:..." or "mailto:..." etc. 2. It wont pay respect to any TARGET attribute These things could of course be tackled by a clever script, which I am sure someone has already written, but actually I would prefer many other things before such a script - for instance to add a submit button or similar, which would work as expected when invoking the click event.
admin
Date:: Aug 22, 2007
Time:: 13:25
dustPuppy, did you get your question solved? If you did then please close this question and distribute the points. If you found the solution on your own, we would be very happy if you could explain it here for the sake other users having the same problem. If you didn't get a solution to your problem, please leave a comment here to let the experts know that you're still looking for an answer. Thanks, The Quomon Admin Team
Date:: Aug 27, 2007
Time:: 05:38
thanks, jgivoni for your response and sorry for not getting back quicker. your proposed solution sounds like a good way to do it. thanks for the help
aviavital
Date:: Jan 12, 2010
Time:: 18:35
great, 3 years after.. I'm using a hidden link to upload files after selecting them from list
onlyab
Date:: Dec 28, 2010
Time:: 23:29
Thanks the author, very useful advice. my pc's internet connection is very slow, which always drive me crazy, I want a program to solve my slow computer, several days ago my friend recommend me a software tuneup360, now I'm waiting for the result.
Question Answered
This question has been closed, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Questions
whats the best food to eat during midnight?
How to identify the tiffany jewelry? www.tffanycheapmall.com.
Send an email alert to each user of the php application based on criteria
How I Increased My AdSense Earnings?
how to choose the lady dress ?
How can I fulfill the minimum requirement to make your computer support 3D?
You have 100 characters to use
Rank
Expert
Points
1.
10354
2.
6493
3.
5596
4.
4848
5.
3487
6.
2840
7.
2770
8.
2303
9.
1820
10.
917
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software