Generate a click on a specific link from JS

Discussion in 'JavaScript' started by alinask, Jan 27, 2010.

  1. #1
    Hi guys. Need your help again. I need help into generating a click when a function is called.
    For example, assume the next link:

    <a href="#" id="spot">click me</a>

    <script>

    function gen()
    {
    generate a click to id spot
    }

    </script>

    I only need to know how to generate a click for lightbox script. Please help.
    or if you know how to call a function with parameters, instead of using this

    <a href="text.html" class="lbOn">About Lightbox</a>

    (will open in light box text.html , but i need to do it automaticly )


    Thank you
     
    alinask, Jan 27, 2010 IP
  2. alexpr07

    alexpr07 Active Member

    Messages:
    284
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #2
    If I understand you correctly, this should be very simple:

    function gen()
    {
    location="text.html";
    }

    </script>

    When the function is executed, it will load text.html page. Is this what you needed?
     
    alexpr07, Jan 27, 2010 IP
  3. alinask

    alinask Active Member

    Messages:
    330
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #3
    @alexpr07 no :( . I need a function that simulate a real mouse left click to a specific ID of <a href. Thank's anyway
     
    alinask, Jan 28, 2010 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't understand "simulate a real mouse click".

    You have an anchor
    <a href="#" id="spot">BLAH</a>

    What exactly is supposed to happen and what is the user expected to do to make that happen? Are users supposed to be clicking on that anchor? Is the script supposed to know to take users to text.html if they click on an anchor with the id of "spot"?
     
    Stomme poes, Jan 28, 2010 IP