Animal
10-23-2006, 03:22 AM
There's a scoping problem in the script loading function.
The code needs to be
var _parseScripts = function(){
var s = this.dom.getElementsByTagName("script");
var docHead = document.getElementsByTagName("head")[0];
// For browsers which discard scripts when inserting innerHTML, extract the scripts using a RegExp
if(s.length == 0){
var re = /(?:<script.*(?:src=[\"\'](.*)[\"\']).*>.*<\/script>)|(?:<script.*>([\S\s]*?)<\/script>)/ig; // assumes HTML well formed and then loop through it.
var match;
while(match = re.exec(html)){
var s0 = document.createElement("script");
if (match[1])
s0.src = match[1];
else if (match[2])
s0.text = match[2];
else
continue;
docHead.appendChild(s0);
}
}else {
for(var i = 0; i < s.length; i++){
var s0 = document.createElement("script");
s0.type = s[i].type;
if (s[i].text) {
s0.text = s[i].text;
} else {
s0.src = s[i].src;
}
docHead.appendChild(s0);
}
}
}.createDelegate(this);
That createDelegate function is a fantastic addition. It helps so much when using DWR callbacks!
The code needs to be
var _parseScripts = function(){
var s = this.dom.getElementsByTagName("script");
var docHead = document.getElementsByTagName("head")[0];
// For browsers which discard scripts when inserting innerHTML, extract the scripts using a RegExp
if(s.length == 0){
var re = /(?:<script.*(?:src=[\"\'](.*)[\"\']).*>.*<\/script>)|(?:<script.*>([\S\s]*?)<\/script>)/ig; // assumes HTML well formed and then loop through it.
var match;
while(match = re.exec(html)){
var s0 = document.createElement("script");
if (match[1])
s0.src = match[1];
else if (match[2])
s0.text = match[2];
else
continue;
docHead.appendChild(s0);
}
}else {
for(var i = 0; i < s.length; i++){
var s0 = document.createElement("script");
s0.type = s[i].type;
if (s[i].text) {
s0.text = s[i].text;
} else {
s0.src = s[i].src;
}
docHead.appendChild(s0);
}
}
}.createDelegate(this);
That createDelegate function is a fantastic addition. It helps so much when using DWR callbacks!