To read the address bar using JavaScript

E

eureka

Hi All,

I need to store the address-bar content of a web page into a string
variable ,

Is there any way I can achieve this through JavaScript?
 
A

ASM

eureka a écrit :
Hi All,

I need to store the address-bar content of a web page into a string
variable ,

Is there any way I can achieve this through JavaScript?

myVar = self.location.toString();
 
R

RobG

eureka said:
Hi All,

I need to store the address-bar content of a web page into a string
variable ,

Is there any way I can achieve this through JavaScript?

var s = window.location.href;
alert( s );
 
E

Evertjan.

RobG wrote on 13 jan 2007 in comp.lang.javascript:
eureka wrote:

var s = window.location.href;
alert( s );

Right,

only the address bar is not part of a web page,
it is not necessarily the same as the web page's URL
that is returned by the above js code,
so you can type into the addressbar, whatever you like,
untill you hit return, that is.

Some browsers could perhaps not even have an address bar,
and still be able to execute js.

However, for the suspected purpose of the OP, the answer is right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top