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 6012235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:22:27+00:00 2026-05-23T02:22:27+00:00

The window.location is an object. But when you execute location.toString() it converts the object

  • 0

The window.location is an object. But when you execute location.toString() it converts the object to the equivalent to location.href.

My question is how? And can I set up objects to a similar behaviour?

  • 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-05-23T02:22:28+00:00Added an answer on May 23, 2026 at 2:22 am

    You can add a toString method to your object that returns what you want. In that case href

    eg:

    var obj = {
      href:'',
      toString:function(){
        return this.href;
      }
    };
    
    obj.href = 'http://stackoverflow.com';
    obj.toString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can use window.location.pathname to return a url, but how do I
There is a very particular edge case in cross-domain policies regarding the window.top.Location object...
when ever i use window.location.href=//some url it always open a new window, this only
What is the difference between JavaScript's window.location.href = window.location.href and window.location.reload() functions?
Take this code snippet for example: window.location.href = 'mysite.htm#images'; Already being on the site
$(#table_exams tbody tr).click(function (event) { window.location.href=# +$(this).attr(exam_ID); window.location.href=/medilab/prototypes/exams/edit?examId= + $(this).attr(exam_ID) +&referer= + referer; row_select(this);
Every property of the window object is a global variable. This means you can
$(document).ready(function(){ setTimeout(function() { window.location.href = $(.user a)[0].href; }, 2000); }); i put the above
Anybody knows why window.location is undefined in ie8 (maybe ie7 too), but works as
Контакты if(window.location == 'http://my.site.com/contacts/') { $('.menuwelcome').css('display', 'block'); $('.leftlink').find('Контакты').css('font-weight', 'bold'); $('#mcontacts').find('a').html('<b>Контакты</b>').remove(); } How do remove

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.