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
    Aug 2005
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting body id?

    Is there a small javascript snippet or something that can dynamically set the body ID on page load? I am using the Inverted Sliding Doors tabs from 456 Berea Street (http://www.456bereastreet.com/lab/inverted_tabs/) but am trying to do so in a frameset [insert angry comments here] (I know I know, please don't harp!)... anyway, the tabs css sets the active tab using the body ID, but I can't seem to get it to recognize the body ID inside the frameset. Is there a javascript or some other code I could use to dynamically set the body ID? Or perhaps a better approach? Thanks.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,296
    Thanks
    10
    Thanked 584 Times in 565 Posts
    Code:
    <script>
    document.getElementsByTagName("body")[0].id="exampleID1"
    </script>

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,627
    Thanks
    0
    Thanked 646 Times in 636 Posts
    Why do you need to give the body an id when document.getElementsByTagName("body")[0] is a unique reference to it without needing an id? You only need to give ids to tags where there can be more than one and you need to identify a specific one.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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