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

100
Views
location.href = 'URL' redirects to a new page not a new website

I am trying to make a project that involves redirecting to another website. I am having trouble doing that.

Here is my code

document.getElementById("ContinueToWeb").onclick = function () {
   location.href = "google.com";
}
<html>
  <head>
    <!--Some code here-->
  </head>
  <body>
    <!--Some code here-->
    <button id="ContinueToWeb">Continue</button>
  </body>
</html>

For some reason, it redirects from c:/folder/index.html to c:/folder/google.com even though I am telling it to go from c:/folder/index.html to google.com. Do you know what's happening?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You have to add the protocol for the link or else it defaults to what the site is using which is your local filesystem. Use https://www.google.com instead

about 4 years ago · Santiago Trujillo 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!