473,320 Members | 1,969 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,320 software developers and data experts.

Synthetic click on link doesn't follow link

Hi,

Below is an example of a synthetic click in Firefox. The browser does
not follow the link. Is that the just the way synthetic clicks work of
am I doing something wrong? I know the synthetic click occurs because
if I add an onclick attribute to the link the handler runs. Any ideas?

Thanks,
Peter

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>

<title>synthetic click</title>

<script type="text/javascript">

window.onload = function() {
var el = document.getElementById('myLink');

var e = document.createEvent("MouseEvents");

e.initMouseEvent('click', // event type
true, // can bubble
true, // cancelable
window, // abstract view
0, // detail
0, // screenX
0, // screenY
0, // clientX
0, // clientY
false, // ctrl key
false, // alt key
false, // shift key
false, // meta key
0, // button
null); // related target

el.dispatchEvent(e);

}

</script>

</head>
<body>

<p><a id="myLink" href="http://www.yahoo.com">myLink</a></p>

</body>
</html>

Jun 4 '07 #1
2 2270
On Jun 3, 8:42 pm, Peter Michaux <petermich...@gmail.comwrote:
Hi,

Below is an example of a synthetic click in Firefox. The browser does
not follow the link. Is that the just the way synthetic clicks work of
am I doing something wrong? I know the synthetic click occurs because
if I add an onclick attribute to the link the handler runs. Any ideas?

After some more research I discovered that this is a known problem.
The solution is just to manually set the location.href property.

Thanks for reading.

Peter

Jun 4 '07 #2
Peter Michaux wrote:
On Jun 3, 8:42 pm, Peter Michaux <petermich...@gmail.comwrote:
>Hi,

Below is an example of a synthetic click in Firefox. The browser does
not follow the link. Is that the just the way synthetic clicks work of
am I doing something wrong? I know the synthetic click occurs because
if I add an onclick attribute to the link the handler runs. Any ideas?


After some more research I discovered that this is a known problem.
The solution is just to manually set the location.href property.
Can you provide the location of this solution?

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 5 '07 #3

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

Similar topics

2
by: Nigo | last post by:
Hi there Is it posible to make a link (to a php-file on a server) in an email that, when you click on it, sends info about who the reciver of the email is? Lets say I send out an email thru...
6
by: Dave Patton | last post by:
Discussions in another thread, about the use of multiple "Top" links on a page prompted me to redo a page of mine: http://members.shaw.ca/davepatton/mapcompare.html was changed to:...
21
by: news.btinternnet.com | last post by:
I can do this in IE myLink.click(); //Invoking the handler as if the user had clicked on the link themselves. I need to be able to do the same in Netscape Navigator, can anyone help ?
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
17
by: Eric | last post by:
I'm new to JavaScript and I wrote this code to play with. Oddly, if I enter text in a box and then press the button, I only get the onChange event for the text box and not the button's onclick...
7
by: Jeff Gaines | last post by:
I have spent the day learning how to use Zend Development Environment. I can now produce a list of files in a directory, filtered by extension, and apparently clickable. Unfortunately clicking on...
5
by: Xu, Qian | last post by:
Hello All, I have some problem by simulating a link click using javascript. The webpage uses a js-library named interface (jQuery like) ------------------------------ <a id="foo" href="#">Try...
1
by: rowland | last post by:
I'm trying to come up with solution for adding synthetic properties to python, similar to synthetic properties in Objective-C. I'm playing around with doing this in a MetaClass. I can...
3
by: jeddiki | last post by:
Hello, I have my site analyzer script nearly working, but the link that I am trying to pass back to the query is not being accepted. The easiest way to explain what I mean is to show you the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.