Confusion between DOM element and javascript object

This is a discussion on "Confusion between DOM element and javascript object" within the JavaScript Forum section. This forum, and the thread "Confusion between DOM element and javascript object are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 22nd, 2007, 00:58
New Member
Join Date: Oct 2007
Location: Sydney
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Confusion between DOM element and javascript object

Hi,

I am having this really strange issue and would result in a javascript error popup in Internet Explorer. When I debug into the script, the problem seems to be that during the execution of some javascript code, IE confused a javascript object with a DOM element (A div).

The code that is causing this issue is below:
Code: Select all
window.Splitter1 = new ComponentArt_Splitter('Splitter1'); Splitter1.Postback = function() { __doPostBack('Splitter1','') }; Splitter1.Panes.Orientation = 1;
The error fails in the third line where IE thinks "Splitter1" is a DIV element instead of the above created javascript object, making "Splitter1.Panes" null. Note: This does not happen all the time, so timing has something to do with this too.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 22nd, 2007, 09:44
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Confusion between DOM element and javascript object

It's very hard to see what could be causing this without seeing the _SPlitter class and remaining code.

Are you able to post that?
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 22nd, 2007, 15:24
New Member
Join Date: Oct 2007
Location: Toronto
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Confusion between DOM element and javascript object

IE makes everything with an id attribute a global variable.

thus if your class generates and adds a div, with that ID, it will be the object that IE refers to, instead of your class instance.

I would *HIGHLY* recommend that in IE you *NEVER* use a variable name with the same label, as an element in your DOM (by ID or by NAME) (IE has issues with both!)



Quote:
Originally Posted by coolxo View Post
Hi,

I am having this really strange issue and would result in a javascript error popup in Internet Explorer. When I debug into the script, the problem seems to be that during the execution of some javascript code, IE confused a javascript object with a DOM element (A div).

The code that is causing this issue is below:
Code: Select all
window.Splitter1 = new ComponentArt_Splitter('Splitter1'); Splitter1.Postback = function() { __doPostBack('Splitter1','') }; Splitter1.Panes.Orientation = 1;
The error fails in the third line where IE thinks "Splitter1" is a DIV element instead of the above created javascript object, making "Splitter1.Panes" null. Note: This does not happen all the time, so timing has something to do with this too.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 22nd, 2007, 23:38
New Member
Join Date: Oct 2007
Location: Sydney
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Confusion between DOM element and javascript object

Unfortunately, the code I showed above is from a third-party tool (ComponentArt) so I do not have any controls over how their javascript objects are created. I may need to take this up with their support then.

But I still do not understand why does it works most of the time? If what you said is correct, shouldn't it breaks all the time? But this error only pops up once every 10 times or something. And once it works, it will always works, until I restart IIS.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice on obtaining an object using javascript. Higel JavaScript Forum 1 May 27th, 2008 18:05
Javascript Copy to clipboard Object Error andrewlondon JavaScript Forum 1 Sep 24th, 2007 13:15
Yet more confusion dhall Starting Out 7 Aug 20th, 2007 23:25
element specific javascript gumbo Web Page Design 0 Dec 4th, 2005 23:27
XHTML Block Element in an Inline Element gohankid77 Web Page Design 6 Jul 27th, 2004 10:15


All times are GMT. The time now is 14:22.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42