PDA

View Full Version : Resolved Modal Doesn't Work in IE



Master_script_maker
04-27-2008, 12:16 AM
I made this modal script and it works perfectly in firefox, but it doesn't work in IE please help.
http://masterproject.freehostia.com/test/drag.html

uppercanuck
04-27-2008, 05:40 PM
First rule of coding HTML: use a valid doc type at the top of your HTML document. That's probably why it doesn't work in IE.

Master_script_maker
04-27-2008, 08:29 PM
i tried it with a valid doctype and it didn't work.

Master_script_maker
04-28-2008, 12:57 PM
can anyone help?

jscheuer1
04-28-2008, 01:40 PM
You cannot:


. . . setAttribute("style", . . .

or:


. . . setAttribute("class", . . .

in IE.


. . . setAttribute("onClick", . . .

probably will not work in IE either, I'm not sure. To be safe, use:


el.onclick=function(){whatever();};

or use the addEventListener() and attachEvent() methods.

A cross browser substitute for the style bit is to set each individual property/value pair, ex:


md.style.width=this.width+"px";
md.style.height=this.height+"px";
md.style.cursor=this.title!=false?"":"move";


A cross browser substitute for the class bit is, ex:


mt.className="drag title";

The setAttribute() method is fraught with other subtle issues, and so should only be used when direct assignment will not work. Example of direct assignments that work (the second of course is only for elements that support the href attribute and url is a defined string var):


el.id='some_id';
el.href=url;

Pretty much all the basic ones and even many of the more esoteric things work this way. The setAttribute() method is good for when the case of the attribute and/or its value is critical in IE, then you can do:


el.setAttribute('frameborder', 1, 0);

the 0 tells IE that regardless of whether or not it should be FRAMEBORDER, or FrameBorder, or frameBorder, IE should just do it right. Other browsers don't care anyway (at least in most cases).

And setAttribute() sometimes just must be used, as doing it any other way (short of writing out the element) won't work.

IE 7 handles fixed position correctly, so you should consider making your conditional:


<!--[if IE]>


<!--[if lt IE 7]>

But, IE 7 may need help with some of those other styles anyway, so this is a decision to be made once you get the other stuff working.

Now, I'm not sure about much of the rest of the code, as we don't really get to see it in action with all these other 'errors', as IE doesn't see the intended created markup to begin with, so thinks that there is nothing to do. Take care of these issues and we shall see what happens.

Master_script_maker
04-28-2008, 08:27 PM
Thank you so much, it worked!