Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers by Nicholas C. Zakas; ISBN: 9780764579080
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 3rd, 2006, 08:17 PM
AGS AGS is offline
Wrox Technical Editor
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: Russia
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default Resolution of property names on window object

I have a question regarding resolution of property names on global object (window object in case of browser hosting environment).

Lets say we have a global variable with the same name as property of a window object.
Code:
var location = "Test";
Global variable is in fact a property of global object (window). So having declared global variable location we cannot access original window.location property anymore.

As far as I know there is no way to access original property of window in this case but maybe someone has a clue?

Interestingly enough it seems that in Firefox window’s property takes precedence over global variable of the same name and for example var location = "Test.html" changes current location.


__________________
Alexey Gorkov
  #2 (permalink)  
Old August 4th, 2006, 04:57 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You'd only be able to access it if you had saved a reference to the original before creating your own variable.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
  #3 (permalink)  
Old August 4th, 2006, 06:18 PM
AGS AGS is offline
Wrox Technical Editor
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: Russia
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Nicholas, that's all I wanted to know.
But what about Firefox? Does its implementation seem logical for you?

  #4 (permalink)  
Old August 5th, 2006, 11:50 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I'm not sure I'd call it "logical". It seems to go against the theory that you may want to override some previously defined variable.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic variable/object names TheBFJ Excel VBA 2 November 13th, 2006 07:11 AM
Refreshing Property Window? Kaprice Visual Studio 2005 11 November 11th, 2006 08:49 PM
Arranging controls according to window resolution bijgupt VB.NET 2002/2003 Basics 0 June 7th, 2006 03:47 AM
Blank Property window... aoskayak BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 3 May 5th, 2006 11:26 AM
Window Names panos Javascript How-To 2 February 10th, 2006 11:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.