By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,460 Members | 1,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,460 IT Pros & Developers. It's quick & easy.

problem with my script and frames

P: n/a
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...ective.user.js
It is too long to post the code on the forum

Joseph Scoccimaro
gt*****@mail.gatech.edu
Nov 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


Joseph Scoccimaro wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.