[ale] JavaScript and server address

James Sumners james.sumners at gmail.com
Mon Jun 4 22:49:21 EDT 2007


I know even less about Java than I do about JavaScript, and I don't
know a lot about JavaScript. I do know that one is not a derivative of
the other.

If you want to get the current URL in the address bar, you just need
to take a look at `window.location`. With a little bit of RegEx magic,
you should be able to get what you need. Here is an example:

<html>
<head>
<script type="text/javascript">
function tmp() { address=window.location; alert(address); }
</script>
</head>
<body>
<input type="button" onclick="tmp();" value="clickme">
</body>
</html>

On 6/4/07, Christopher Fowler <cfowler at outpostsentinel.com> wrote:
>
> On Mon, 2007-06-04 at 20:41 -0400, James Sumners wrote:
> > JavaScript is executed client side so it has no knowledge of the
> > server that served it.
>
> How does a Java Applet know where it came from?  I guess the JVM
> downloads it from the server so it does know the source.
>
> Would it be possible in JavaScript to grab the URL out of the browser
> and then cut the address from it?
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>


-- 
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59



More information about the Ale mailing list