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

  • SEARCH
  • Home
  • 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 8178055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:40:28+00:00 2026-06-06T23:40:28+00:00

I am trying to implement what seems to be very simple JavaScript redirection, via

  • 0

I am trying to implement what seems to be very simple JavaScript redirection, via the following rudimentary command:

window.location.href = "http://www.somesite.com";

So far so good, it works. I also can do it via the following method:

location.replace("http://www.somesite.com");

No problem here, it works again! The problem comes when I loose the protocol out of the string:

window.location.href = "www.somesite.com";

OR:

location.replace("www.somesite.com");

It just appends the new location to the current url:

http://www.currentsite.com/www.somesite.com

Of cause, that’s not what I want. Is there any way to force the redirect?

  • 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-06T23:40:29+00:00Added an answer on June 6, 2026 at 11:40 pm

    One way is to use protocol-relative url like this:

    window.location = "//www.somesite.com";
    

    Or

    window.location = "//somesite.com";
    

    This way, it would redirect and browser itself will take care of figuring out protocol part eg http or https

    Working Example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement my custom security attribute. It's very simple for now [Serializable]
I am trying to implement some very simple Data Binding in my User Control
I'm trying to implement some very simple line drawing animation for my iPhone app.
I was trying to implement multithreaded script execution in Unity3d, but it seems that
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
I am trying to provide a very simple Do you wish to save this
I have been trying to integrate my very simple voice recorder app with the
I got a little problem here guys. I'm trying to implement the following scenario:
I'm trying to make a very simple iphone app that displays the real-time camera
I'm trying to implement a little server service in order to upload files via

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.