471,598 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How a child window can read a parents stylesheet ?

Folks,
I have a script that pops a calendar up - its a generic script that I
use across some of my webapps - I would like the script to be
intelligent enough to set its fonts and other colours to be the same
as the parent window that requested the window.open in the first
place.

How do I do this? My webapp users are majority IE7 but a few of us
prefer Firefox2 so something that is near cross-browser compatable
would be great.

Thanks!

Aug 20 '07 #1
8 3780
In article
<11*********************@o80g2000hse.googlegroups. com>,
"Randell D." <fi************@gmail.comwrote:
Folks,
I have a script that pops a calendar up - its a generic script that I
use across some of my webapps - I would like the script to be
intelligent enough to set its fonts and other colours to be the same
as the parent window that requested the window.open in the first
place.

How do I do this? My webapp users are majority IE7 but a few of us
prefer Firefox2 so something that is near cross-browser compatable
would be great.
The script pops the window up. The content of the window is what?
Some html file? If so, just put a link to the wanted stylesheet
in it.

--
dorayme
Aug 20 '07 #2
On Mon, 20 Aug 2007 14:03:07 -0700, "Randell D."
<fi************@gmail.comwrote:
I would like the script to be
intelligent enough to set its fonts and other colours to be the same
as the parent window
Intelligence is bad here: it's harder to implement, and the user might
have switched it (client-side JS) off. Of course, you're using a
fallback of a <a href link and not just JavaScript, aren't you?

Instead, do it server-side. Just embed the same link to the same
stylesheet in both pages.

If you want some level of customisation within the site, keep the
stylesheet the same but change an overall class within this. This is
more robust - at least it falls back to some default if it doesn't get
subclassed correctly. Easiest way to do it is still largely server-side,
by passing the "context" as a command line parameter.
Aug 20 '07 #3
Randell D. wrote:
I have a script that pops a calendar up
Bah. I hate those. If I were you I'd let the user just enter the date and
make the parsing very tolerant.

Any fans of mile-long pop-ups for country names or credit card expiration
dates out there?

robert
Aug 21 '07 #4
Rik
On Tue, 21 Aug 2007 12:23:45 +0200, Robert Latest <bo*******@yahoo.com>
wrote:
Randell D. wrote:
>I have a script that pops a calendar up

Bah. I hate those. If I were you I'd let the user just enter the date and
make the parsing very tolerant.

Any fans of mile-long pop-ups for country names or credit card expiration
dates out there?
My favourite is a double option: enter the date manually or click a little
button next to it to click it/'browse to it' in an inline calender pop up,
which fills the manual inputs.
--
Rik Wasmus
Aug 21 '07 #5
Rik wrote:
On Tue, 21 Aug 2007 12:23:45 +0200, Robert Latest <bo*******@yahoo.com>
wrote:
>Randell D. wrote:
>>I have a script that pops a calendar up

Bah. I hate those. If I were you I'd let the user just enter the date and
make the parsing very tolerant.

Any fans of mile-long pop-ups for country names or credit card expiration
dates out there?

My favourite is a double option: enter the date manually or click a
little button next to it to click it/'browse to it' in an inline
calender pop up, which fills the manual inputs.
Mine is dodgy JavaScript for the droplist boxes like the USPS's postage
calculator page when selecting a destination country from the mile-long
list that trap the click and not the change so the whole page reloads
with the *wrong* country before you can select the *right* one. A real
joy on dialup!

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Aug 21 '07 #6
On Aug 20, 11:03 pm, "Randell D." <fiprojects....@gmail.comwrote:
Folks,
I have a script that pops a calendar up - its a generic script that I
use across some of my webapps - I would like the script to be
intelligent enough to set its fonts and other colours to be the same
as the parent window that requested the window.open in the first
place.

How do I do this? My webapp users are majority IE7 but a few of us
prefer Firefox2 so something that is near cross-browser compatable
would be great.
I have included folk from the javascript community this time around as
the solutions suggested by the stylesheet group is not what I am
looking for.

Thus - can someone tell me how a child window can take the CSS of its
parent opening window?

Thanks...

Aug 21 '07 #7
On Aug 21, 1:27 am, Andy Dingley <ding...@codesmiths.comwrote:
On Mon, 20 Aug 2007 14:03:07 -0700, "Randell D."

<fiprojects....@gmail.comwrote:
I would like the script to be
intelligent enough to set its fonts and other colours to be the same
as the parent window

Intelligence is bad here: it's harder to implement, and the user might
have switched it (client-side JS) off.
Clients all have javascript enabled - it is a web application and
users know its a requirement.
Instead, do it server-side. Just embed the same link to the same
stylesheet in both pages.

If you want some level of customisation within the site, keep the
stylesheet the same but change an overall class within this. This is
more robust - at least it falls back to some default if it doesn't get
subclassed correctly. Easiest way to do it is still largely server-side,
by passing the "context" as a command line parameter.
No - this won't work for me either as my child window is dynamically
created and depends entirely on the parent for information... thus...
how can I query the parent opening window, read its CSS and utilise it
within the child window?
Aug 21 '07 #8
Randell D. said the following on 8/21/2007 6:01 PM:
On Aug 20, 11:03 pm, "Randell D." <fiprojects....@gmail.comwrote:
>Folks,
I have a script that pops a calendar up - its a generic script that I
use across some of my webapps - I would like the script to be
intelligent enough to set its fonts and other colours to be the same
as the parent window that requested the window.open in the first
place.

How do I do this? My webapp users are majority IE7 but a few of us
prefer Firefox2 so something that is near cross-browser compatable
would be great.

I have included folk from the javascript community this time around as
the solutions suggested by the stylesheet group is not what I am
looking for.

Thus - can someone tell me how a child window can take the CSS of its
parent opening window?
Include the same CSS file, definitions, etc into the child window.

Otherwise, you are going to have to write a CSS/HTML parser to determine
the styles from the parent window and apply them to a child window. Why
make it harder than it has to be?

<link rel="stylesheet" href="theSameFileAsTheParent.css">

And then give your elements in the child window the same classes as your
parent window.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 21 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Suzanne Vogel | last post: by
reply views Thread by WillWeGetOurFreedomBack | last post: by
2 posts views Thread by chuckdfoster | last post: by
8 posts views Thread by Rick | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.