AaronNGray said:
I have the following Javascript and am trying to get it to work on IE.
It works on FF, Chrome, , Safari, and Opera fine.
http://www.aarongray.org/CompLangJavascript/Test/test.html
If that actually works in FF, Chrome, Safari, and Opera, then by
coincidence.
tag.style.zIndex = 101;
tag.style.cssFloat = "right";
tag.setAttribute("style.float","right");
tag.style.y = 0;
tag.style.width = 32;
tag.style.height = 32;
must be at least
tag.style.zIndex = "101";
tag.style.cssFloat = "right";
tag.style.top = "0";
tag.style.width = "32px";
tag.style.height = "32px";
see <
http://www.w3.org/TR/DOM-Level-2-Style/ecma-script-binding.html>.
BTW, setting an attribute with the name `style.float' to the value `right'
is nonsense. (Have you ever seen `<... style.float="right">...</...>'?)
To make it work in IE/MSHTML, you will also at least need to branch for the
MSHTML DOM:
var sFloat = "right";
if (typeof tag.style.cssFloat != "undefined")
{
tag.style.cssFloat = sFloat;
}
else if (tag.style.styleFloat != "undefined")
{
tag.style.styleFloat = sFloat;
}
See <
http://msdn.microsoft.com/en-us/library/ms530755(VS.85).aspx>
(ignore the MS misnomer: `style' is a CSS _property_, not an attribute.)
The `sFloat' variable is not necessary, but it eases maintenance.
`test' is an identifier unwise to choose; unit testing frameworks (e.g.
JSUnit) may provide a function of the same name, and the identifier is not
self-explanatory anyway.
It works using normal CSS but not done as Javascript.
I am trying to add a gif to the top right of a web page using
Javascript.
<
http://jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork>
<
http://jibbering.com/faq/#javascriptErrors>
PointedEars