Log in

View Full Version : location-esque function?



kosi
01-17-2007, 07:52 PM
Is there a function in php that works like the document.location object in javascript? And if not, is there a way to merge php with javascript? I want to write a function that returns a different value for a variable depending on the document.location, but I have no idea how to do this. Thanks.

Twey
01-17-2007, 08:03 PM
$loc = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

kosi
01-17-2007, 08:23 PM
Thanks, I actually wouldn't have thought to do that . . . but I'm looking for something that will find the location of any frame in the window, including the topmost, not just the one in which the php script resides. I want to compare the url of the "current" frame against the url of the "top" frame.

Twey
01-17-2007, 08:39 PM
Then no, I'm afraid not. You'll have to use Javascript to get the values, then possibly pass them to PHP via an XMLHttpRequest.

kosi
01-17-2007, 08:56 PM
How would i do that?

Twey
01-17-2007, 09:45 PM
Read http://www.w3schools.com/ajax/default.asp for a basic introduction.