1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

javascript redirection with onmousemove

Discussion in 'HTML & JavaScript' started by jampack, Jan 6, 2011.

  1. jampack

    jampack Newbie

    Joined:
    Dec 20, 2009
    Messages:
    43
    Likes Received:
    2
    hi,
    i want to know is it possible to click on a specific link on a webpage using onmousemove function
    please provide me sample script also
    Thanks
     
  2. OhaiBBQ

    OhaiBBQ Newbie

    Joined:
    May 26, 2009
    Messages:
    25
    Likes Received:
    35
    yes, attach a closure to the onmousemove event, in the closure find the link you want and change the window.location to that link's href attribute
     
    • Thanks Thanks x 1
  3. JesusBack

    JesusBack Executive VIP Premium Member

    Joined:
    Sep 15, 2010
    Messages:
    1,159
    Likes Received:
    1,284
    Occupation:
    Almost done :D
    Location:
    {calm|cool|collected}
    Code:
    <script type="text/javascript">
    function go {
    window.location = "http://www.google.com";
    }
    <a href="http://www.blackhatworld.com" onmouseover="go()" >hi</a>
    8 minutes~. hope it works :)
     
  4. jampack

    jampack Newbie

    Joined:
    Dec 20, 2009
    Messages:
    43
    Likes Received:
    2
    this is a mouseover script and i was asking for onmousemove
    Means when a person move his mouse that action gets triggered.
     
  5. GreyWolf

    GreyWolf Executive VIP Jr. VIP

    Joined:
    Aug 17, 2009
    Messages:
    1,930
    Likes Received:
    5,387
    Gender:
    Male
    Occupation:
    Artist / Craftsman
    Location:
    sitting at my PC
    OhaiBBQ already gave you the answer.

    if you didn't understand what he meant then try this
    Code:
    <html>
    <head>
    <title>onmousemove open new page</title>
    
    <script type="text/javascript">
       window.onmousemove = mousemoved;
          function mousemoved()
          {
           window.location.href='http://yourREDIRECTpage.com';
          }
    </script>
    
    </head>
    <body>
    
    <p>move the mouse pointer anywhere on the page<br />
    will cause redirect page to load.</p>
    
    </body>
    </html>
     
    • Thanks Thanks x 1
  6. jampack

    jampack Newbie

    Joined:
    Dec 20, 2009
    Messages:
    43
    Likes Received:
    2
    Thanks to OhaiBBQ and GreyWolf
    That script is working perfect for me
    and i was just looking for it