problem with my script and frames

J

Joseph Scoccimaro

Currently I have a Greasemonkey script that adds a menu to the top of every
page by adding its self to the DOM. I am having a problem when I visit a
page with frames. The menu gets duplicated in every frame. I know the
problem is that the menu gets appended to the body of all the documents in
the different frames. Is there a way around this without having to use
JavaScript to break out of frames? Currently I am using this to insert the
menu div tag into the body tag: theBody.insertBefore(menuDiv,
theBody.childNodes[0]);

If you need to look at my whole script it is at this location:
http://www.prism.gatech.edu/~gte542u/testdetective.user.js
It is too long to post the code on the forum

Joseph Scoccimaro
(e-mail address removed)
 
M

Martin Honnen

Joseph said:
Currently I have a Greasemonkey script that adds a menu to the top of every
page by adding its self to the DOM. I am having a problem when I visit a
page with frames. The menu gets duplicated in every frame. I know the
problem is that the menu gets appended to the body of all the documents in
the different frames. Is there a way around this without having to use
JavaScript to break out of frames?

If Greasemonkey automatically calls your script for every window and
frame then your script can check e.g.
if (window == top)
to find out whether it is currently executed in the top level window
containing the frameset document.
But a menu more likely belongs into a particular frame I suppose so for
named frames you could check
if (window.name == 'someFrameName')
and then inject whatever you want to inject and don't do anything for
the other windows/frames.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top