Select Categories Below
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.
Advertisement
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
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
how do i open a file dialog in .net (a windows application)?
When trying to alter a table in MySQL, I get "Error on rename... (Errcode: 13)"
how do i delete a top domain cookie from a subdomain?
Hi Am Rakesh, Am generating User Data List, Details Given Below.Please Help Me.
What is some free software for recording the movements on your computer screen t...
Good project management software?
You have 100 characters to use
Rank
Expert
Points
1.
1022
2.
928
3.
875
4.
240
5.
220
6.
125
7.
75
8.
9.
10.
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 Real Estate Postcards Marketing Fulfillment