PDA

View Full Version : Possible script conflict, only affecting Internet Explorer



djvk87
11-29-2010, 12:48 AM
1) Script Title:
Drill Down Menu (v1.6)
&
Dynamic Ajax Content

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex1/drilldownmenu.htm
&
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

3) Describe problem:
When using the two of these scripts in conjunction (using the Drill Down Menu links to load Dynamic Ajax Content) the Dynamic Ajax Content breaks in Internet Explorer with the error: 'document.getElementById(...)' is null or not an object.

However it works flawlessly in mozilla firefox, for an example view the following URL in both firefox and Internet Explorer:
http://woodenboatshop.com.au/yanmar/scriptconflicttest.php

I have had this problem for quite some time, and I have looked for conflicts between the two scripts but have come up with no solutions. I'm not a master with scripts so I'm out of ideas as to what it could be and would really appreciate any help I can get here.

Thank You.

djr33
11-29-2010, 02:04 AM
document.getElementById() is known to be somewhat problematic in IE.

You can google it for more info. A lot of results show up. One is that name and id elements get confused in IE7 and earlier. Another is that apparently the id cannot be a reserved/used system property.

http://stubblog.wordpress.com/2007/02/06/documentgetelementbyid-vs-ie/

Anyway, to cut a long story short, and to stop you spending as much time reading this post as I did finding the problem, it turns out that IE cannot handle global variables with the same name as an DOM element ID, especially if that variable is actually pointing at that DOM node!!

Does that help?

Try changing the id to something else and maybe it will work. The two scripts in this case should not be a problem, but perhaps using them together creates a problem with an id named something unusual.

djvk87
11-29-2010, 04:17 AM
Thanks, I'll have a go at that.
I really hope I can get it to work as I spent a lot of time setting up a system using these two scripts on my businesses website.

I noticed the problem while I was still working on it but figured I'd be able to solve it. I suppose in hindsight I should have either solved it then and there or changed to another script that didn't conflict in IE.

djvk87
11-29-2010, 05:45 AM
Well I tried to figure out how to change the name of the variable, or make the variable local to the function in the Dynamic Ajax Content script. But everything I tried just broke the script.

I'm not the best with Javascript you see, which is why I used the scripts premade here. I can disable the Drill Down Menu and the Dynamic Content works fine, but it really needs the menu.

Pretty much I'm stumped for ideas, I've looked for an alternate menu system that has the overall same effect but I can't find one. And even if I did change the menu system I'd need one that uses <li> and <ul> tags for the structure otherwise I'd have to rewrite a lot of code. That and I really like the Drill Down Effect.

I want to use both these scripts in conjunction and I just wish IE wouldn't stuff everything up all the time.