Results 1 to 9 of 9

Thread: Popup Menu in PHP

  1. #1
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Popup Menu in PHP

    I've created Popup menus that work fine in HTML pages (www.anakhacoman.com), but for some reason these same menus aren't working on a PHP page (www.anakhacoman.com/blog)

    Any help appreciated - thanks!

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    The problem is here:

    Code:
    <script language="JavaScript" src="mm_menu.js"></script>
    You're using that same code on both pages, but on the blog page, you've gone down one directory, so you need to change the "src" attribute to either:

    Code:
    <script language="JavaScript" src="../mm_menu.js"></script>
    or

    Code:
    <script language="JavaScript" src="/mm_menu.js"></script>
    The second option may be preferred, as it will always start you at the root directory, so it doesn't matter how many directories down you are.

  3. The Following User Says Thank You to Schmoopy For This Useful Post:

    wispsofsmoke (11-10-2010)

  4. #3
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    The second option may be preferred, as it will always start you at the root directory, so it doesn't matter how many directories down you are.
    Hi Schmoopy - does the single "/" start you from the root on all systems?
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No - the .../ goes down one directory. I'm pretty sure that just the / does nothing.
    Jeremy | jfein.net

  6. #5
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    So, if in doubt, its probably safest to use an absolute path or something like href="<?php 'http://'.$_SERVER['HTTP_HOST']?>/path/to/js/script.js" in the case of an application where you dont know the domain. (I think)
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  7. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    What do you mean? If I had a script file in /scripts/blah.js, and I was running an html file in files/blah.html, to link from files/blah.html, I would do: ../scripts/blah.js which would go up one level the parent directory, and then find the folder scripts.
    Jeremy | jfein.net

  8. #7
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Quote Originally Posted by Nile View Post
    No - the .../ goes down one directory. I'm pretty sure that just the / does nothing.
    / Does not do nothing, having just tested it, it definitely goes to the root directory. True, it may be just as easy to use:

    Code:
    $_SERVER['DOCUMENT_ROOT'];
    But / will do the job.

  9. #8
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks - it's working now!

    Amazing how sometimes it comes down to something so simple . . .

  10. #9
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Schmoopy View Post
    / Does not do nothing, having just tested it
    Proven wrong.
    Jeremy | jfein.net

Bookmarks

Posting Permissions

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