rawsweets
08-01-2003, 10:30 PM
[ Same message, with a plea for others to respond, even if it is to confirm whether this is possible or not. ]
Hello all,
I'm trying to catalog all the functions declared in a page, for
debugging purposes, but I can't seems to access code from external libraries in
IE.
I have successfully captured inline functions, by searching the "text"
property of each element of the "document.scripts" array. In NS/Moz, thankfully, you can access any global entity (like a function) in the "top" object, inline or external. (Does anyone know how this works with Safari/Omni clients?)
Back to my problem:
In IE, as I understand it, external libraries don't have a text property to search
- it seems that the "text" property basically refers to the code between the actual SCRIPT tags and NOT the code inserted by an external file.
I'm keeping my hopes up, that code from an externally loaded file is in an accessible area of IE's DOM - perhaps in one of their infamous collections?... Any ideas?
Below is a rudimentary example of how I've successfully captured
function declarations in IE and NS/Moz.
/snip------------
// browser flag
isIE = (navigator.appName.toString().indexOf('Micro') != -1) ? 1 : 0;
// alias document object
DC = document;
// if client is IE compatible...
if (isIE) {
// alias document.scripts array
var s = DC.scripts;
// loop through and catalog functions per script
for (var i = 0; i < s.length; i++) {
// initial search index
var x = 0;
// until the entire script text has been searched
while (s[i].text.indexOf('function ',x) != -1) {
// capture next starting index
x = s[i].text.indexOf('function ',x) + 9;
// write next declared function
DC.write('<P>',s[i].text.substring(x,s[i].text.indexOf('(',x)),'<\/P>');
}
}
} else { // otherwise if client is netscape compatiblae
// loop through and display top-level entities
for (var i in self) {
// if this is a function, write name to page
if (typeof(self[i]) == 'function') DC.write('<P>',i,'<\/P>');
}
}
------------snip/
Like I said before, I can't test this on Safari or Omni... Would someone let me know how this script performs with these clients?
- Thanks much!
Hello all,
I'm trying to catalog all the functions declared in a page, for
debugging purposes, but I can't seems to access code from external libraries in
IE.
I have successfully captured inline functions, by searching the "text"
property of each element of the "document.scripts" array. In NS/Moz, thankfully, you can access any global entity (like a function) in the "top" object, inline or external. (Does anyone know how this works with Safari/Omni clients?)
Back to my problem:
In IE, as I understand it, external libraries don't have a text property to search
- it seems that the "text" property basically refers to the code between the actual SCRIPT tags and NOT the code inserted by an external file.
I'm keeping my hopes up, that code from an externally loaded file is in an accessible area of IE's DOM - perhaps in one of their infamous collections?... Any ideas?
Below is a rudimentary example of how I've successfully captured
function declarations in IE and NS/Moz.
/snip------------
// browser flag
isIE = (navigator.appName.toString().indexOf('Micro') != -1) ? 1 : 0;
// alias document object
DC = document;
// if client is IE compatible...
if (isIE) {
// alias document.scripts array
var s = DC.scripts;
// loop through and catalog functions per script
for (var i = 0; i < s.length; i++) {
// initial search index
var x = 0;
// until the entire script text has been searched
while (s[i].text.indexOf('function ',x) != -1) {
// capture next starting index
x = s[i].text.indexOf('function ',x) + 9;
// write next declared function
DC.write('<P>',s[i].text.substring(x,s[i].text.indexOf('(',x)),'<\/P>');
}
}
} else { // otherwise if client is netscape compatiblae
// loop through and display top-level entities
for (var i in self) {
// if this is a function, write name to page
if (typeof(self[i]) == 'function') DC.write('<P>',i,'<\/P>');
}
}
------------snip/
Like I said before, I can't test this on Safari or Omni... Would someone let me know how this script performs with these clients?
- Thanks much!