A
Alvaro G. Vicario
The code below inserts a <span> tag around the image. It works fine in
Firefox or Opera, but has a weird effect in Internet Explorer: browser
keeps loading the image forever... Even though the picture *is* displayed,
status bar and throbber won't stop showing activity. Apart from that,
scripts work even in IE.
Is it an IE bug or is there something wrong with my code? I've googled
about it but couldn't find the right keywords...
The snippet comes from a larger function that surrounds a given node
(possibly with child nodes) with a new node. So if I have:
<p>Foo <strong>bar</strong></p>
I'd call surroundWithNewNode(p, 'div') and get:
<div><p>Foo <strong>bar</strong></p></div>
It's annoying that I can't use it against <img> tags
==== >8 ==================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title></title>
<style type="text/css"><!--
p, span, #pic{
padding: 5px;
}
p{
background-color: white;
}
#pic{
padding: 10px;
background-color: black;
}
span{
background-color: green;
}
--></style>
</head>
<body>
<p>This is <img id="pic" src="http://www.google.es/images/hp0.gif"> a
picture</p>
<p>If you can see green, scripts works.</p>
<script type="text/javascript"><!--
var pic=document.getElementById('pic');
var span=document.createElement('span');
span.appendChild(pic.cloneNode(true));
pic.parentNode.replaceChild(span, pic);
//--></script>
</body>
</html>
==== >8 ==================
Thank you in advance,
Firefox or Opera, but has a weird effect in Internet Explorer: browser
keeps loading the image forever... Even though the picture *is* displayed,
status bar and throbber won't stop showing activity. Apart from that,
scripts work even in IE.
Is it an IE bug or is there something wrong with my code? I've googled
about it but couldn't find the right keywords...
The snippet comes from a larger function that surrounds a given node
(possibly with child nodes) with a new node. So if I have:
<p>Foo <strong>bar</strong></p>
I'd call surroundWithNewNode(p, 'div') and get:
<div><p>Foo <strong>bar</strong></p></div>
It's annoying that I can't use it against <img> tags
==== >8 ==================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title></title>
<style type="text/css"><!--
p, span, #pic{
padding: 5px;
}
p{
background-color: white;
}
#pic{
padding: 10px;
background-color: black;
}
span{
background-color: green;
}
--></style>
</head>
<body>
<p>This is <img id="pic" src="http://www.google.es/images/hp0.gif"> a
picture</p>
<p>If you can see green, scripts works.</p>
<script type="text/javascript"><!--
var pic=document.getElementById('pic');
var span=document.createElement('span');
span.appendChild(pic.cloneNode(true));
pic.parentNode.replaceChild(span, pic);
//--></script>
</body>
</html>
==== >8 ==================
Thank you in advance,