Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2004
    Location
    France
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem with a getElementById in Firefox !

    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
    PHP Code:
    <link rel="stylesheet" href="css1.css" type="text/css" id="pStyle"
    PHP Code:
    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 :
    PHP Code:
    <script type="text/javascript"
    document.write('<LINK REL=stylesheet id="cStyle" HREF="'+parent.document.getElementById('pStyle').href+'" TYPE="text/css">'
    </script> 
    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 :
    PHP Code:
    <script language="JavaScript1.2"
    document.write('<LINK REL=stylesheet HREF="'+parent.styleSheet+'" TYPE="text/css">'
    </script> 
    Then, on a page in a subdirectory :
    PHP Code:
    <script type="text/javascript"
    document.write('<LINK REL=stylesheet id="cStyle" HREF="../'+parent.document.getElementById('pStyle').href+'" TYPE="text/css">'
    </script> 
    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
    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...
    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 !!!!!
    Ness

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Link comes back 404 Not Found.

  • #3
    New Coder
    Join Date
    Feb 2004
    Location
    France
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oups, sorry... Anyway, it's okay, I solved my problem. thanks !!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •