SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Feb 2002
    Location
    NZ
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Clicking on image

    Can anybody help me with making Javascript simulate clicking on an image in a form? (EG: <input type=image>)
    I already know how to make it simulate clicking on a "submit" button in a form.
    window.document.forms[0].elements["submit"].click();
    Input type "submit" supports this click() method, but it appears that input type "image" does not.

    Thanks guys.

  2. #2
    SitePoint Enthusiast Wouter's Avatar
    Join Date
    Jan 2002
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello -- the following code will work in IE but not in NS
    and that is the problem I'm currently struggling with. I'm using NS 7.x, NS 6.x and IE 6.x.

    <html>
    <head>
    <title>proxy click() test (W3C DOM)</title>
    <script type="text/javascript">
    function action1() { return true; }
    function action2() { return true; }
    function action3() { alert('This Works'); }
    </script>
    </head>

    <body>

    <form name="form1" id="form1">
    <a href="#"
    onmouseout="action1();"
    onmouseover="action2();"
    onclick = "action3();"
    >
    <img src="image1.gif" border="0" name="image1" id="image1">
    </a></form>

    <form>
    <a href="#"
    onclick = "document.getElementById('image1').click();"
    >
    <img src="image2.gif" border="0">
    </a></form>

    </body>
    </html>

  3. #3
    SitePoint Guru
    Join Date
    Feb 2002
    Location
    NZ
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thankyou !!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •