View Full Version : Popup Menu in PHP
wispsofsmoke
11-10-2010, 06:49 AM
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!
Schmoopy
11-10-2010, 07:24 AM
The problem is here:
<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:
<script language="JavaScript" src="../mm_menu.js"></script>
or
<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.
Beverleyh
11-10-2010, 12:32 PM
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?
No - the .../ goes down one directory. I'm pretty sure that just the / does nothing.
Beverleyh
11-10-2010, 01:25 PM
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)
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.
Schmoopy
11-10-2010, 11:09 PM
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:
$_SERVER['DOCUMENT_ROOT'];
But / will do the job.
wispsofsmoke
11-10-2010, 11:11 PM
Thanks - it's working now!
Amazing how sometimes it comes down to something so simple . . .
/ Does not do nothing, having just tested it
:D Proven wrong.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.