473,543 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.styleS heets

The problem is that
document.getEle mentById('IFid' ).document.styl eSheets

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 1931


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.styleS heets

The problem is that
document.getEle mentById('IFid' ).document.styl eSheets

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="iframeNam e" src="whatever.h tml"></iframe>
then you can script
var iframeDoc;
if (window.frames && window.frames.i frameName) {
iframeDoc = window.frames.i frameName.docum ent;
// change iframeDoc.body. style.backgroun dColor 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="iframeNam e" src="whatever.h tml"></iframe>
: then you can script
: var iframeDoc;
: if (window.frames && window.frames.i frameName) {
: iframeDoc = window.frames.i frameName.docum ent;
: // change iframeDoc.body. style.backgroun dColor 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.getEl ementById('IFid ').document.sty leSheets

or in Gran'Ma's JS

parent.MiIframe .document.bgCol or="#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
3635
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 parent class, and I can't make some "helper" class a friend of the parent class to help in accessing the data.) Problem: I want to derive a...
2
1581
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 define a new menuitem in the inherited class and add it to the parent class. for example my parent class menubar is (New, Edit, Delete, Exit). inherited...
1
1933
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 html dynamically for the layout I want. I have seen some examples of using a repeater and they seem to be the thing to use when you don't want a...
1
1054
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 some controls in there. what i'm trying to archive here is once the close button in the child window in fired up, i want it to handle the event in...
7
2016
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'. How should I declare classes so that all three functions are executed when child class is called? Class Parent public function ONE 'code end...
1
1788
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? The class Nest has a subclass SubNest. Within SubNest I want to work with Title. I think if I can pass Title ByRef to the children and...
2
1473
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 the same process that the parent one, but with a postgres database, thus I've got to use diferent type variables to acces the database. There's...
1
3316
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. When my Default page loads I'd like to set SkinID for each of these controls.
9
2626
by: Steven Powers | last post by:
Imagine the following setup class Parent { virtual void doStuff(); } class Child : public Parent { virtual void doStuff(); }
0
7411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7354
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5888
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5282
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4898
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3394
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
643
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.