jibonita
20 Apr 2007, 7:04 AM
Hi,
i had my code this way:
<script language="javascript">var sLogo='<img src="images/logo.jpg">'</script>
so i think the code above first finds opening script and then the srcRe finds src from the variable sLogo, and this is wrong. I get an error. This is a bug right.
Code::
YAHOO.util.Event.onAvailable(id, function(){
var hd = document.getElementsByTagName("head")[0];
var re = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img;
var srcRe = /\ssrc=[\'\"]([^\'\"]*)[\'\"]/i; // <------ this changed
var match;
while(match = re.exec(html)){
var srcMatch = match[0].match(srcRe);
if(srcMatch && srcMatch[1]){
var s0 = document.createElement("script");
s0.src = srcMatch[1];
hd.appendChild(s0);
}else if(match[1] && (match[1].length != 0)){ //<----- this changed too
eval(match[1]);
}
}
var el = document.getElementById(id);
if(el){el.parentNode.removeChild(el);}
if(typeof callback == 'function'){
callback();
}
});
i had my code this way:
<script language="javascript">var sLogo='<img src="images/logo.jpg">'</script>
so i think the code above first finds opening script and then the srcRe finds src from the variable sLogo, and this is wrong. I get an error. This is a bug right.
Code::
YAHOO.util.Event.onAvailable(id, function(){
var hd = document.getElementsByTagName("head")[0];
var re = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img;
var srcRe = /\ssrc=[\'\"]([^\'\"]*)[\'\"]/i; // <------ this changed
var match;
while(match = re.exec(html)){
var srcMatch = match[0].match(srcRe);
if(srcMatch && srcMatch[1]){
var s0 = document.createElement("script");
s0.src = srcMatch[1];
hd.appendChild(s0);
}else if(match[1] && (match[1].length != 0)){ //<----- this changed too
eval(match[1]);
}
}
var el = document.getElementById(id);
if(el){el.parentNode.removeChild(el);}
if(typeof callback == 'function'){
callback();
}
});