S
Sudrien
I'm writing a bookmarklet that creates a prompt in a iframe in the
current html document. This works (mostly) - except for framesets.
In Firefox, I can loop through the frames, calculating the one with
the largest area, like so:
/* console.warn("uh oh - frameset"); */
frames = document.getElementsByTagName('frame');
var biggest = 0; /* the biggest frame #, by pixel area, is
probably the content. */
for (var i = 1; i < frames.length; i++) {
if ( frames.contentWindow.innerHeight *
frames.contentWindow.innerWidth >
frames[biggest].contentWindow.innerHeight *
frames[biggest].contentWindow.innerWidth) { biggest = i; }
}
/* now we have the biggest frame. can we write to it? */
var head =
frames[biggest].contentDocument.getElementsByTagName('head')[0];
script = document.createElement('script');
script.id = 'makeMark';
script.type = 'text/javascript';
script.src = '...';
head.appendChild(script);
However, IE (or IE7 at least) does not seem to support 'contentWindow'
to the same extent. How can I do the same thing in IE?
Note: this script is run after being added to the current document in
a similar way (get head, append info to head)
-Sud.
current html document. This works (mostly) - except for framesets.
In Firefox, I can loop through the frames, calculating the one with
the largest area, like so:
/* console.warn("uh oh - frameset"); */
frames = document.getElementsByTagName('frame');
var biggest = 0; /* the biggest frame #, by pixel area, is
probably the content. */
for (var i = 1; i < frames.length; i++) {
if ( frames.contentWindow.innerHeight *
frames.contentWindow.innerWidth >
frames[biggest].contentWindow.innerHeight *
frames[biggest].contentWindow.innerWidth) { biggest = i; }
}
/* now we have the biggest frame. can we write to it? */
var head =
frames[biggest].contentDocument.getElementsByTagName('head')[0];
script = document.createElement('script');
script.id = 'makeMark';
script.type = 'text/javascript';
script.src = '...';
head.appendChild(script);
However, IE (or IE7 at least) does not seem to support 'contentWindow'
to the same extent. How can I do the same thing in IE?
Note: this script is run after being added to the current document in
a similar way (get head, append info to head)
-Sud.