Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Greasemonkey script to change colors on a website with nested framesets.

    I've been trying to find out how to change the background color of a particular webpage by creating a Greasemonkey script (using Firefox here). The problems arise when apparently I need to target each frame individually. How do I refer to them? Being a noob to javascript (god, even that is an overstatement), I've tried gazillion different combinations of commands (code) to acheive this, so far I've had two kinds of results: only the first frame (named menupane) gets altered or nothing gets altered.

    Here's the source code of the website:

    Code:
    <html>
    <head><title>The Kingdom of Loathing</title>
    </head>
    <frameset id=rootset cols="4*,*">
    	<frameset id=menuset rows="50,*">
    		<frame name=menupane src="topmenu.php" scrolling=no></frame>
    		<frameset id=mainset cols="200,*">
    			<frame name=charpane src="charpane.php">
    			<frame name=mainpane src="main.php"></frame>
    		</frameset>
            </frameset>
    	<frame name=chatpane src="chatlaunch.php"></frame>
    </frameset>
    </html>
    (KoL, a whacky RPG, kingdomofloathing.com).
    Anyway... this code only changes the frame named 'menupane'. Nothing else. I had the impression that 'window' was the topmost object and all frames are its obedient bit-- slaves. I guess not.
    Code:
    window.document.bgColor="black"

    This piece of work (one of the thousands) I came up with changes absolutely nothing. Zip. Zero. Ever been that noob coder trying to figure out the correct order of things, or what is even remotely appropriate code with zero guidance?
    Code:
    window.frames['rootset'].frames['menuset'].frames['mainset'].frames['charpane'].document.bgColor="black"

    Here are some things to be taken into consideration:
    - No other Greasemonkey script can't conflict with this script since I've disabled them during the testing (got dozen other scripts to alter that website).
    - I know about the feature in Firefox with which you can change the background and text color in ALL pages, but really, I just want to invert the colors on this one website, since too much white starts to hurt my eyes after a while. Google will be next. Are there any other options than Greasemonkey to acheive this kind of thing ("simple" change of colors on user's end)?

    Has Googling for javascript tutorials been helpful? Yes, a little. Confusing? Twice so.

    I just want the background to be black and text white/light grey... I'll figure out the colors once I can target the frames correctly.
    Is there any other information I might provide that might be essential in troubleshooting this?
    Thank you in advance.
    Last edited by Cleesh; 03-29-2008 at 03:32 AM.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by Cleesh View Post
    Code:
    window.frames['rootset'].frames['menuset'].frames['mainset'].frames['charpane'].document.bgColor="black"
    did u try

    Code:
    window.frames['charpane'].document.bgColor="black";
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just did. Pretty sure that exact line was among one of the first attempts. I wish it worked, but it doesn't (no visible change). Also, Error Console (in Firefox: Tools -> Error Console) says

    window.frames.charpane has no properties

    It's always saying something similar. Bla bla has no properties, depending on the code that was attempted.
    Last edited by Cleesh; 03-29-2008 at 11:36 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •