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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OnLoad condition based on web address

    I am using an expandable and collapseable menu on my site. In the body tag I can use the OnLoad command to tell the menu which category I would like open. However, I am using the same menu on multiple pages and want the OnLoad to be dynamic based on what the web address is. I can't put the OnLoad on each page becuase those pages are dynamic as well and one file can be many different pages. Is there a way to set a function based on what the web address is and then use that in that function in the OnLoad.

    I hope I made my goals clear as I know it's a bit confusing.

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Maybe something like:

    PHP Code:
    $page $_SERVER['PHP_SELF']; 
    if (
    $page index.php) {
    menu_a
    }
    if (
    $page contact.php) {
    menu_b

    Leonard Whistler

  • #3
    New Coder
    Join Date
    Jun 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks that helps. Now this is probally dumb but what do I put in the OnLoad

    OnLoad=('$page');

    ????

    Is correct?

  • #4
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by zkoneffko View Post
    Thanks that helps. Now this is probally dumb but what do I put in the OnLoad

    OnLoad=('$page');

    ????

    Is correct?
    Mixing PHP and Javascript can be messy. I'm not familiar with OnLoad, I think you would be better off posting that question in the Javascript forum.




    ----
    Leonard Whistler


  •  

    Posting Permissions

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