HighDots Forums  

window.location or window.location.href?

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss window.location or window.location.href? in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
monkeydd
 
Posts: n/a

Default window.location or window.location.href? - 04-10-2009 , 11:57 PM






Im not sure how to do window.location?
is this right?

<script type="text/javascript" >window.location.href='http://
www.google.com';</script>

Reply With Quote
  #2  
Old   
RobertVA
 
Posts: n/a

Default Re: window.location or window.location.href? - 04-12-2009 , 10:01 PM






monkeydd wrote:
Quote:
Im not sure how to do window.location?
is this right?

script type="text/javascript" >window.location.href='http://
www.google.com';</script
"location" is a sub-object/property of the "window" object, thus it can
be referred to as "window.location".

For your purposes you could load a new page by just making an assignment
to the entire "window.location" property/object.

I found an example at
http://www.w3schools.com/js/tryit.as...tryjs_location within the
example's newLocation() function.

Although "window.location.href" also seems to work. The "entire URL"
href property (of window.location) appears to be a bit redundant. Other
properties of "windows.location" could be useful for reading or changing
portions of the URL like domain/host names and port numbers (which are
sometimes not stated - permitted to remain the default).


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.