473,834 Members | 1,761 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 1948


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
3659
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 class that has a copy constructor that properly copies those data members.
2
1591
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 class: (New, Edit, Delete, Report, Exit) thanks
1
1947
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 table of results, but I'm not sure how to change the <ItemTemplate> depending on the contents of the...
1
1063
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 the parent window. below are my codes, hope you can help me Dim objPanel As New GATTA.InstanceMgmt...
7
2041
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 fuction
1
1802
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 grandchildren, it would work, but VB doesn't do so by default, and indeed warns me against it: "Reference to a...
2
1487
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 one big function in the class that does all the DB stuff, and I want to know if there's any way to...
1
3324
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
2639
by: Steven Powers | last post by:
Imagine the following setup class Parent { virtual void doStuff(); } class Child : public Parent { virtual void doStuff(); }
0
10793
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10509
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10547
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10219
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5626
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3977
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3081
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.