Simulating click doesn't work with Mozilla in some cases

Discussion in 'Javascript' started by firefox.coder, Dec 8, 2005.

  1. I'm writing code that plays back web transactions by acting like a real
    user. I'm currently trying to get this working in Mozilla-based
    browsers. I simulate mouse clicks with the following code (where node
    is the element I'm sending the click to):

    var evt = node.ownerDocument.createEvent('MouseEvents');
    evt.initMouseEvent('click', true, true, node.ownerDocument.defaultView,
    1, 0, 0, 0, 0, false, false, false, false, 0, null);

    This works in almost all cases, links, buttons, images within links,
    Starting with Firefox 1.5, this stopped working on simple popups
    (prompt, confirm, alert, basic auth) It worked on Firefox 1.0.x and
    Mozilla 1.7.2. What's strange is that it has actually worked in
    Firefox 1.5 a few times but I have no idea why. I've probably tried it
    at least 50 times while trying to debug.

    Another case is gmail. I've never gotten this to work when I want to
    simulate a click on an email message in gmail. I'm sure that I've got
    the right node during playback, but the click doesn't do anything. I'm
    not sure if gmail is doing something funny on the page or if there's
    some problem with this being in an iframe which is in a frame. My code
    handles Frames and IFrames just fine on other web sites.

    In the cases where this doesn't work, there is no exception or
    javascript error. The function keeps executing like nothing happened.
    firefox.coder, Dec 8, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.