IE 7 New Element problem

14 views
Skip to first unread message

kstubs

unread,
Aug 23, 2011, 1:59:27 PM8/23/11
to prototype-s...@googlegroups.com
I'm getting something undefined (see generated source below) from this:

var img = new Element('img', {'src':'/Resources/Library.Images/transparent.gif', 'usemap':'#' + company, 'style': 'width:' + args.width + '; height:' + args.height + ';'});

This is in IE7.  Do you see an issue in or around 'style'?

Generated source:

<IMG style="Z-INDEX: 1; WIDTH: 730px; HEIGHT: 90px" height=1 src="/Resources/Library.Images/transparent.gif" width=1 undefined="width:730px; height:90px;" usemap="#poway">

Victor

unread,
Aug 24, 2011, 2:39:27 AM8/24/11
to prototype-s...@googlegroups.com
I used similar things with
 new Element(tagName, {style:"..."})
earlier, but after strange behavior of IE I prefer to use
 new Element(tagName).setStyle({width:x,height:y})

kstubs

unread,
Aug 24, 2011, 5:01:04 PM8/24/11
to prototype-s...@googlegroups.com
If indeed setStyle is working and not the former, then it would seem to me that the issue could easily be traced back to the root of the problem.  Perhaps someone of the Prototype dev team can have a look into this.

Karl..

kstubs

unread,
Aug 24, 2011, 9:38:08 PM8/24/11
to prototype-s...@googlegroups.com
So this:
var form = new Element('form', {id:'MSO_LOGON', action:'#', method:'post', style:'display:none'});

Renders this:
<FORM id=MSO_LOGON style="DISPLAY: none" action=# method=post _prototypeUID="12" undefined="display:none"></FORM>


Notice the undefined above.

Walter Lee Davis

unread,
Aug 24, 2011, 10:05:50 PM8/24/11
to prototype-s...@googlegroups.com
I find with IE of any flavor, that it helps a lot to break this up
into separate steps, rather than the lovely one-liner you have here.

var f = new Element('form'); // IE may be having kittens with form as
a variable name
//maybe insert it somewhere in the page, too, before you start working
on it further
$('someDiv').insert(f);
f.hide(); //same as setStyle('display:hidden');
f
.writeAttribute
('id
','MSO_LOGON
').writeAttribute('action','#').writeAttribute('method','post');

I'm not sure that's absolutely required, but whenever IE starts acting
up with new Element, that's the first thing I start doing. Test to see
how much you can get away with stashing in the initial new Element
call, also test putting quotes around your keys in the hash, style out
in the open like that seems to be the critical factor.

Walter

> --
> You received this message because you are subscribed to the Google
> Groups "Prototype & script.aculo.us" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/t3-L4Ssy1OgJ
> .
> To post to this group, send email to prototype-s...@googlegroups.com
> .
> To unsubscribe from this group, send email to prototype-scripta...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en
> .

kstubs

unread,
Aug 25, 2011, 1:17:05 AM8/25/11
to prototype-s...@googlegroups.com
Yeah, I'm recoding a bunch of these right now.  Bummer.  Seems like this could be fixed.  

Karl..
Reply all
Reply to author
Forward
0 new messages