Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
Redirect to another page after mouse counter

I want to redirect to another page if counter > 5. Can you please help me? This is my code:

<p class="times"> 
     <span id="display">0</span> 
</p>    
      
<script type="text/javascript">
    var count = 0;
    var disp = 0;
    var btn = document.getElementById("btn");
    var disp = document.getElementById("display");
          
    btn.onclick = function () {
        count ++;
        disp.innerHTML = count;
    }
    
</script>
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can do that with location.href = "".

<p class="times"> 
     <span id="display">0</span> 
</p>    
      
<script type="text/javascript">
    var count = 0;
    var disp = 0;
    var btn = document.getElementById("btn");
    var disp = document.getElementById("display");
          
    btn.onclick = function () {
        count ++;
        disp.innerHTML = count;
        if (count > 5) {
             location.href = "https://google.com/";
        }
    }
    
</script>
about 4 years ago · Juan Pablo Isaza Report

0

btn.onclick = function () {
    count ++;
    disp.innerHTML = count;
    if(count > 5) {
        //this will change the location of the window object aka. redirect
        window.location.href = 'http://my_addreess.com';
    }
}
about 4 years ago · Juan Pablo Isaza Report

0

<p class="times"> 
    
            <span 
            id="display">0</span> 
     </p>
     <button id='btn'>click</button>
        
      
        <script type="text/javascript">
            var count = 0;
            var disp = 0;
            var btn = document.getElementById("btn");
            var disp = document.getElementById("display");
      
            btn.onclick = function () {
                count ++;
                disp.innerHTML = count;
                if (count == 5)window.location.href="https://www.stackoverflow.com"
            }
            
        </script>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!