Current location: Hot Scripts Forums » General Web Coding » JavaScript » change background colour of another frame

change background colour of another frame

Reply
  #1 (permalink)  
Old
Newbie Coder
 
Join Date: May 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
change background colour of another frame

I was wondeirng if there was anyway of changing the colour of another frame when you click on a link/image.

i have a music player in my left frame so when you click to enter the site, music plays throughout, but i need to change the background colour of that frame when i move from the splash page to the mainsite

Hope someone can help!!!
Thanks!
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
To make a reference to another frame using JavaScript you use the frames collection and the window object like this:

window.parent.frames['other_frame_name' or other_frame_id_no].document.body.style.backgroundColor="blue"
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #3 (permalink)  
Old
Newbie Coder
 
Join Date: May 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
sorry, but im not so experienced with javascript
how would i implement that so when i click the intro pic, it went to the main news.php site and changed the background colour of the left frame to oragne.

THANKS!
Reply With Quote
  #4 (permalink)  
Old
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
I don't know exactly how to do it since I don't know what your frameset looks like.

For the image use an onclick event like this: <img src="pic.jpg" onClick="window.parent.frames[0].document.body.backgroundColor='orange';">
I'm just guessing that you have two frames and the left frame has id 0.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #5 (permalink)  
Old
Newbie Coder
 
Join Date: May 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
my left frame is called leftFrame

how do i give it an id number?
Reply With Quote
  #6 (permalink)  
Old
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Each frame is automatically given an id number. Which one depends on the order in which they appear in the source, starting at 0.
You can either use the id number or the frame name when referring to a fram in the frames collection, like this:
frames['leftFrame'] is the same as frames[0] if the left frame comes first in the frameset. (which would be logical if you only have two frames)
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #7 (permalink)  
Old
Newbie Coder
 
Join Date: May 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
hmmm cant seem to get it to work
Reply With Quote
  #8 (permalink)  
Old
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
This would be easier if you posted a link to your page or posted the sourcecode for the frameset page and the two other pages in question.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #9 (permalink)  
Old
Newbie Coder
 
Join Date: May 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
LEFT FRAME:
<body><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="20" height="15">
<param name="movie" value="sideplayermusic.swf">
<param name=quality value=high>
<param name="wmode" value="transparent">
<embed src="sideplayermusic.swf" width="20" height="15" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent"></embed>
</object></td>
</tr>
</table>
</body>

MAIN FRAME:
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><a href="news.php" "><img src="rickstarnew.gif" onClick="window.parent.frames[0].document.body.backgroundColor='orange'; width="800" height="525" border="0"></a></td>
</tr>
</table> </td>
</tr>
</table>
</body>

FRAMESET:
<frameset cols="20,*" frameborder="NO" border="0" framespacing="0">
<frame src="leftblack.htm" name="leftFrame" scrolling="NO" noresize>
<frame src="indexmid.html" name="mainFrame">
</frameset>
<noframes><body>
</body></noframes>
Reply With Quote
  #10 (permalink)  
Old
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Sorry, looks like I tricked you, it should be body.style.backgroundColor

However, you seem to have a double quotation mark too much in the href attribute and you forgot one after the onClick event..
<td align="center"><a href="news.php"><img src="rickstarnew.gif" onClick="window.parent.frames[0].document.body.style.backgroundColor='orange';" width="800" height="525" border="0"></a></td>
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
td background change on mouseover HoT DaWg CSS 1 05-08-05 02:14 PM
Please help change background colour Masuma The Lounge 1 05-02-05 12:33 PM
change colour of selected row in listview vbsoftwareengineer Visual Basic 0 02-19-05 10:35 AM
pls HELP VB 5.0 colour change K Z Visual Basic 1 12-10-04 03:19 AM
How can I change the gray background of an applet? laxy_m Everything Java 1 09-29-04 05:24 PM


All times are GMT -5. The time now is 05:32 AM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.