Page 1 of 1

Capturin URL in JavaScript

Posted: Fri Jan 16, 2004 6:16 am
by mzfp2
Hi

is it possible to read the current URL in the address bar when a page loads using JavaScript?

Thanks

http://www.alljammin.com -Free funky dating and flirting

Posted: Fri Jan 16, 2004 8:59 am
by kettle_drum
Ummm pretty sure yo can with somthing like:

self.location

or maybe

window.location

I know ive used it before, but cant quite remember.

Solution

Posted: Sun Jan 18, 2004 6:33 am
by anjanesh

Code: Select all

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function GetURL(srcID)
 &#123;
 alert(document.location.href); 
 &#125;
</SCRIPT>
</HEAD>
<BODY>
<INPUT type="button" value="Button" id=button1 onclick="GetURL(this)">
</BODY>
</HTML>

Posted: Sun Jan 18, 2004 12:39 pm
by jaxn
You posed this same question a couple of days ago.
viewtopic.php?t=16799

Why use JavaScript? Why not use this:
$requested_url = $_SERVER['REQUEST_URI'];

Are you trying to get the parent of a frame?

-Jackson

Posted: Thu Jan 22, 2004 4:58 am
by mzfp2
Well im trying to implement faceparty functionality so if someone types say http://www.alljammin.com/shizzle it should diaplay shizzle's profile.

However the only way I can implement is to put a script in my custom 404 error pages which traps the page nout found error, and captures the URL, and reads the username from it, then does a redirect