473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

changing css class from parent

Hi,

I have this situation:

I have a main page with content and an IFRAME on it.
The IFRAME has it's own style sheet and the body of that uses a class:

<body class="IFbody">

How can I change the backgroundcolor of the IFRAME via a function in the
main page, activated from the main page.
The scripts I found via google only access the styles on the main page via
for example
document.styleSheets

The problem is that
document.getElementById('IFid').document.styleShee ts

Does not access the IFRAME stylesheet but the main page stylesheet.

Any suggestion how to access it, would be great.
Wouter
Jul 20 '05 #1
3 1920


DJ WIce wrote:
I have a main page with content and an IFRAME on it.
The IFRAME has it's own style sheet and the body of that uses a class:

<body class="IFbody">

How can I change the backgroundcolor of the IFRAME via a function in the
main page, activated from the main page.
The scripts I found via google only access the styles on the main page via
for example
document.styleSheets

The problem is that
document.getElementById('IFid').document.styleShee ts

Does not access the IFRAME stylesheet but the main page stylesheet.

Any suggestion how to access it, would be great.


You need to access the document in the iframe, a way to do that is to use
<iframe name="iframeName" src="whatever.html"></iframe>
then you can script
var iframeDoc;
if (window.frames && window.frames.iframeName) {
iframeDoc = window.frames.iframeName.document;
// change iframeDoc.body.style.backgroundColor here
}
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

: > Any suggestion how to access it, would be great.
:
: You need to access the document in the iframe, a way to do that is to use
: <iframe name="iframeName" src="whatever.html"></iframe>
: then you can script
: var iframeDoc;
: if (window.frames && window.frames.iframeName) {
: iframeDoc = window.frames.iframeName.document;
: // change iframeDoc.body.style.backgroundColor here
: }

Cool it works..
So instead of using it's ID, give it a name and it wil listen ;-)

Thanks!
Wouter
Jul 20 '05 #3
@SM
DJ WIce a ecrit :

Cool it works..
So instead of using it's ID, give it a name and it wil listen ;-)


with your code does that would work ?

parent.MiIframe.document.getElementById('IFid').do cument.styleSheets

or in Gran'Ma's JS

parent.MiIframe.document.bgColor="#ffffcc';

--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
************************************************** ************
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Suzanne Vogel | last post by:
Hi, Given: I have a class with protected or private data members, some of them without accessor methods. It's someone else's class, so I can't change it. (eg, I can't add accessor methods to the...
2
by: newbie_csharp | last post by:
Hi, I try to change the menubar in an inhertied class. in the parent class, the menuitem is protected. I can clear it in the inherited class but I cannot add a new menuitem to it. how can I...
1
by: Henry Nelson | last post by:
Hi all I'm very new to dotNet and just trying to get my head around the right way to do the thing that I would normally do in asp. In asp I would loop through a recordset and output all the...
1
by: Parkos Totito | last post by:
Greetings I've got this parent window which opens a child window, once the child window closes it refreshes the parent window. there is a panel control in the parent window which i'm using to hide...
7
by: msxkim | last post by:
How to execute functions in the parent class first and then functions in the child class? For example, I have a parent class with functions 'ONE' and 'TWO' and child class has a function 'THREE'. ...
1
by: Yuk Tang | last post by:
Leading on from a recent topic, "How does child class access parent's variables", I would like to ask, what's the most elegant way of changing a parent/grandparent/great-grandparent's property? ...
2
by: mrclash | last post by:
Hello, I have a class that uses some variables to access a sql database, and I want to make a derived class that inherits all the methods of this class, because the derived one will do exactly...
1
by: V | last post by:
Hello! I made custom control with tables and labels in it. In my page I have several of these controls. Each one should have different color of tables etc. I have different SkinIDs for that....
9
by: Steven Powers | last post by:
Imagine the following setup class Parent { virtual void doStuff(); } class Child : public Parent { virtual void doStuff(); }
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.