Connecting Tech Pros Worldwide Help | Site Map

difference between location.href and window.location.href?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 01:38 PM
saiho.yuen
Guest
 
Posts: n/a
Default difference between location.href and window.location.href?

Hi,

Is anyone know what is the difference between Location.href and
Window.location.href

Thanks you very much:)

Saiho



  #2  
Old July 23rd, 2005, 01:38 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: difference between location.href and window.location.href?



saiho.yuen wrote:
[color=blue]
> Is anyone know what is the difference between Location.href and
> Window.location.href[/color]

Both (Location.href and Window.location.href) will yield a script error,
if you are talking about location.href and window.location.href (notice
the different case of the first letter) then there is no difference in
global scope as you can reference global properties (e.g. those of the
window object) as both
propertyName
or
window.propertyName

--

Martin Honnen
http://JavaScript.FAQTs.com/
  #3  
Old July 23rd, 2005, 01:38 PM
Ben Measures
Guest
 
Posts: n/a
Default Re: difference between location.href and window.location.href?

saiho.yuen wrote:[color=blue]
>
> Is anyone know what is the difference between Location.href and
> Window.location.href[/color]

Ignoring the capitalisation errors, there is no difference.

If you specify window.location.href without the 'window.' it is
implicitly referenced.

--
Ben M.
  #4  
Old July 23rd, 2005, 01:39 PM
kaeli
Guest
 
Posts: n/a
Default Re: difference between location.href and window.location.href?

In article <ncE1d.60335$WH1.1164697@wagner.videotron.net>,
dontwantspam@yahoo.com enlightened us with...[color=blue]
> Hi,
>
> Is anyone know what is the difference between Location.href and
> Window.location.href
>
> Thanks you very much:)
>[/color]

Javascript is case-sensitive.
window.location.href

There's a window object.
The window object has a location object as one of its properties.
The location object has href as a property.

As to the difference between the two, the difference comes up when it's not
really
window.location.href
but more like
top.location.href

You see a lot of references say window.location.href when what they really
mean is ANY window object.

So the following would all do different things in a nested frameset depending
on exactly where they executed:
self.location.href="default.html";
top.location.href="default.html";
parent.location.href="default.html";
top.frames[2].location.href="default.html";
top.opener.location.href="default.html"; // only for popup

I believe most browsers infer the window object as self if it isn't
specified, but I don't know that that is guaranteed. I myself always specify
the full window.location.href, JIC.

HTH
--
--
~kaeli~
Do not taunt Happy Fun Ball!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.