View Full Version : problem with a getElementById in Firefox !

04-23-2005, 04:10 PM
Hi !!!!
I have an extra complicated page, and, as a matter of fact, it works fine in IE, as well as every crappy things on this world... lol !!
My problem is, I want my site to be compatible with at least firefox and opera ( it doesn't work with Netscape, no idea why... ).
My problem is simple, I think. But I don't know why it's a problem...
Let me explain this a bit better....
My page has an iframe inside, and it has also a style switcher in javascript ( and before someone pops up with an evil javascript saying, I don't mind having javascript on my website... ).
I'm coming to the main thing : the inner pages all have a single javascript line, telling them to get the style from the parent's page. It works fine on IE, and on all browsers too, but if the pages are in subdirectories, and not on the site root, the style doesn't apply...

that's the main page, accueil.php

<link rel="stylesheet" href="css1.css" type="text/css" id="pStyle">

var styleSheet='css1.css'; // this one is a javascript variable, which changes according to the styles in use. that's on the main page.

On an inner page, on the same level as the accueil.php file :

<script type="text/javascript">
document.write('<LINK REL=stylesheet id="cStyle" HREF="'+parent.document.getElementById('pStyle').href+'" TYPE="text/css">')

Don't pay attention to the long js thing. The main point is to get the css from the parent. You can also write it like that :

<script language="JavaScript1.2">
document.write('<LINK REL=stylesheet HREF="'+parent.styleSheet+'" TYPE="text/css">')

Then, on a page in a subdirectory :

<script type="text/javascript">
document.write('<LINK REL=stylesheet id="cStyle" HREF="../'+parent.document.getElementById('pStyle').href+'" TYPE="text/css">')

The last one works fine on IE, but not on FF mac and PC and Opera...
Most strangely, in Opera, the inner page's background remains white, whereas the background turns black in Firefox.
The background is supposed to be black, but it seems that Opera doesn't get the style sheet at all, and Firefox gets a tiny bit of it...

Any idea why ? I don't really get why it's not working. It simply shows the basic css ( white background, black font, blue links... )

If you want to have a look at the site :
Website (http://psychomoa.free.fr/accueilmoi.php)
In the menu, if you click on Divers, then on Livre de Platine, or Remerciements, you'll see some fake pages I put there, in subdirectories, to see if it works.
The styles are just below the iframe. Test the violet one. The white one is not much different from the default browser's style, and I haven't made anything for the rest for the moment.
It's very clear, if you first click on violet when you arrive on the site, and then, you go to divers and livre de platine, the inner page will appear with a white background in FF... :confused:
If you click on Divers, FAQ, you'll see how it's supposed to appear...

Any help will be greatly appreciated !!! I can put all the files in the root directory, but it'll be mess to update everything, and I'll have like ten thousand files named form.pgp, post.php, admin.php and all, so... It would be great to be able to keep the subdirectories !!!!
Thanks a lot !!!!!

Harry Armadillo
04-23-2005, 10:01 PM
Link comes back 404 Not Found.

04-24-2005, 08:21 AM
Oups, sorry... Anyway, it's okay, I solved my problem. thanks !!!