jquery name attribute of map element in IE -
the following jquery works fine in firefox me, failed in ie6:
$("<map></map>").attr("name",somevar).appendto("#someelement");
the problem map element never gets name attribute generated can prove calling alert($("#someelement").html());
, fact image associated doesn't have links
if use instead, works fine:
$("<map name='" + somevar + "'></map>").appendto("#someelement");
i'm happy use second line of code, wondering if else has had problem...or explanation of why didn't work (i'm wondering specific name attribute)...
(html output first , second scenario):
ie6 using first line:
<map><area shape=rect coords=0,0,300,110 href="http://google.com"></map><img height=215 src="include/nav-images/main.png" width=591 usemap=#tehmap>
ie6 using second line:
<map name=tehmap><area shape=rect coords=0,0,300,110 href="http://google.com"></map><img height=215 src="include/nav-images/main.png" width=591 usemap=#tehmap>
(this more comment material, it's long have no choice post answer. might point in right direction.)
some results investigations, using ie 8 operating in ie 7 mode (which exhibits problem):
$('<map />').attr('x', 'abc').wrap('<div />').parent().html() "<map x="abc"></map>"
...it can correctly set other element of map
tag. wait...
>>$('<map />').attr('name', 'abc').attr('name') "abc"
so getting set. reason html returned .html()
leaves out. why? actual object right, it's not rendering markup correctly.
even more strangely:
>>$('#dummy').append($('<map />').attr("name", "abc")) >>$('#dummy').html() "<map></map>"
but if @ html according ie developer tools, it's...
<map submitname="abc"/>
i investigated bit further, , found question:
weird behaviour of iframe `name` attribute set jquery in ie
and relevant quote accepted answer:
so appears happening ie-up-to-7 redirects use of attributes called name otherwise-invisible property, internally called submitname, form fields changes data field generate part of form submission, doesn't change real name attribute used htmlcollection indexing, radio-grouping, getelementsbyname, or, in case of [i]frames, targeting.
this seems case element uses name
attribute semantically. example:
>>$('#dummy').append($('<div />').attr("name", "abc")) >>$('#dummy').append($('<input />').attr("name", "abc")) >>$('#dummy').html() "<div name="abc"></div><input>"
so appears strange manifestation of relatively commonplace ie bug, simple that. have workaround, i'd stick -- luck else can come along , explain little better.
Comments
Post a Comment