I noticed that the evalScripts method does not take care of script
elements, which point to js files, but only evals the inline contents
of the scripts. I've made a modification of that method, which handles
that, and it seems to work, at least in firefox.
evalScripts: function() {
var head = document.getElementsByTagName('head')[0];
var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
var source = new RegExp('<script[^>]*?src=["\'](.*?)["\'][^>]*?><\/
script>', 'im');
var result = this.extractScripts().map(function(script) { return
eval(script) });
result.push((this.match(matchAll) || []).map(function(scriptTag) {
var match = scriptTag.match(source);
if (match && match[1])
return head.appendChild(new Element('script', {src: match[1],
type: 'text/javascript'}));
}));
return result;
}
I also have a few other methods, which might be useful for the core
prototype:
For the String object:
createTextNode: function() {
if (this == "")
return document.createTextNode(this);
var div = document.createElement('div');
div.innerHTML = this.stripTags();
return div.firstChild;
}
which creates a text node from the string.
and for Elements:
getText: function(element) {
element = $(element);
if (element.textContent)
return element.textContent;
else if (element.innerText)
return element.innerText;
}
which gets the inner text of the element (seems to work in firefox,
opera and ie)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---