Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:31:32+00:00 2026-06-09T08:31:32+00:00

<script type=text/javascript> var IE = document.all?true:false if (!IE) document.captureEvents(Event.MOUSEMOVE) document.onmousemove = getMousePos; // Temporary

  • 0
<script type="text/javascript">
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMousePos;
// Temporary variables to hold mouse x-y pos.s
var tempX = 30;
var tempY = 30;

function getMousePos(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch/correct negative values 
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  

  // show the position values in the form
  document.MouseDisplay.MouseX.value = tempX;
  document.MouseDisplay.MouseY.value = tempY;
  return true;
}

// execute function
if (tempY < 30) {
 alert('tempY is found to be less than 30');
}

</script>

I found this code at hotscript and codelifter http://www.codelifter.com/main/javascript/capturemouseposition1.html, it was from an old thread but I believe it’s got what I need to achieve. I want to execute a function whenever the mouse Y position is less than 30.

I’m a beginner at programming, hope that I can slowly learn from samples here.

My question is, why is the alert command not triggered? What am I missing here. I did a simple button to call the function it works tho.

<script type="text/javascript">
function myFunction() {
alert('tempY is found to be less than 30');
}
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:31:33+00:00Added an answer on June 9, 2026 at 8:31 am

    Haven’t tried your code but assuming it does work when the mouse moves, to see your alert just move that line inside the function :

    var IE = document.all?true:false
    if (!IE) document.captureEvents(Event.MOUSEMOVE)
    document.onmousemove = getMousePos;
    // Temporary variables to hold mouse x-y pos.s
    var tempX = 30;
    var tempY = 30;
    
        function getMousePos(e) {
          if (IE) { // grab the x-y pos.s if browser is IE
            tempX = event.clientX + document.body.scrollLeft
            tempY = event.clientY + document.body.scrollTop
          } else {  // grab the x-y pos.s if browser is NS
            tempX = e.pageX
            tempY = e.pageY
          }  
          // catch/correct negative values 
          if (tempX < 0){tempX = 0}
          if (tempY < 0){tempY = 0}  
    
          // show the position values in the form
          document.MouseDisplay.MouseX.value = tempX;
          document.MouseDisplay.MouseY.value = tempY;
    
          // execute function
          if (tempY < 30) {
           alert('tempY is found to be less than 30');
          }
          return true;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<script type=text/javascript> var chart; $(document).ready(function() { // Define the options var options = {
#!/usr/bin/perl print Content-type: text/html \n\n; print qq(<html> <head> <script type=text/javascript src=/jquery.js></script> <script> jQuery(document).ready(function(){ jQuery(#form_lang).submit(function(e){
I use the next code from Google for Analytics: <script type='text/javascript'> var _gaq =
Here's my code: <script type=text/javascript> (function() { window.PinIt = window.PinIt || { loaded:false };
<script type=text/javascript> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-123-2']); _gaq.push(['_trackPageview']); (function() { var
I have an inline script on my page as such: <script type=text/javascript> var rootPath
Here is fragments of my HAML view: %script{:type => text/javascript, :src => assets/application.js} :javascript
I have this code <html> <head> <script src=jquery-1.7.2.min.js type=text/javascript></script> <script src=jquery-ui-1.8.20.custom.min.js type=text/javascript></script> <script type
When I check this code in Firebug, the entire block is disabled. <script type=text/javascript>
I have a jQuery script: $.ajax({ url: /scripts/secure/development/ajax.asp, type: POST, dataType: text, data: cmd=addresses,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.