473,394 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

addressbar?

Hi,

is it possible to read out the Addressbar with javascript or do I have to
use php for it?
Thank you!

--
roN
www.rideon.ch
Jul 23 '05 #1
13 1875
Do you want to read the current URL? Use document.location

Jul 23 '05 #2
gobera wrote:
Do you want to read the current URL? Use document.location

yup, hm, document.location.... does return the actual domain? like
www.google.com/index.htm?

--
roN
www.rideon.ch
Jul 23 '05 #3
"Ron Eggler" <NO****@hotmail.com> wrote in message
news:3e************@individual.net...
gobera wrote:
Do you want to read the current URL? Use document.location

yup, hm, document.location.... does return the actual domain? like
www.google.com/index.htm?


It's window.location.href (or simply location.href). And why not try it:

<script type="text/javascript">
alert(window.location.href);
</script>

More about the Location object: <url:
http://docs.sun.com/source/816-6408-10/location.htm />

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #4
"Grant Wagner" schrieb:
"Ron Eggler" <NO****@hotmail.com> wrote [...]:
gobera wrote:
Do you want to read the current URL? Use document.location

yup, hm, document.location.... does return the actual domain? like
www.google.com/index.htm?


It's window.location.href (or simply location.href).


Or even more simple `location' :)
PointedEars
Jul 23 '05 #5
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message
news:42***********************@newsread2.arcor-online.net...
"Grant Wagner" schrieb:
"Ron Eggler" <NO****@hotmail.com> wrote [...]:
> gobera wrote:
>> Do you want to read the current URL? Use document.location
> yup, hm, document.location.... does return the actual domain? like
> www.google.com/index.htm?


It's window.location.href (or simply location.href).


Or even more simple `location' :)


I don't like assigning a String value to a Location object, no matter
what the underlying implementation does for me and I think it was a
mistake to implement it that way. It interferes with trying to teach
proper OO concepts, and leads to statements like "JavaScript supports
associative arrays" because the concept of objects, properties and
methods becomes hazy and meaningless.

For the sake of 5 characters, location.href self-documents what is
occurring and I'll continue to both use and recommend it.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #6
"Grant Wagner" schrieb:
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote [...]
"Grant Wagner" schrieb:
It's window.location.href (or simply location.href). Or even more simple `location' :)


I don't like assigning a String value to a Location object, no matter
what the underlying implementation does for me and I think it was a
mistake to implement it that way.


Well, using `location' instead of `location.href' workarounds the
Same Origin Policy by design, so you really should consider it.
It interferes with trying to teach proper OO concepts,
On the contrary. It teaches that an object has a value and still more
properties.
and leads to statements like "JavaScript supports associative arrays"
because the concept of objects, properties and methods becomes hazy
and meaningless.
I think if people want to have misconceptions, there is no way talking
them out of them.
For the sake of 5 characters,
.... and another lookup operation probably reducing efficiency ...
location.href self-documents what is occurring and I'll continue to
both use and recommend it.

PointedEars
Jul 23 '05 #7
Thomas 'PointedEars' Lahn wrote:
"Grant Wagner" schrieb:

"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote [...]
"Grant Wagner" schrieb:

It's window.location.href (or simply location.href).

Or even more simple `location' :)
I don't like assigning a String value to a Location object, no matter
what the underlying implementation does for me and I think it was a
mistake to implement it that way.

Well, using `location' instead of `location.href' workarounds the
Same Origin Policy by design, so you really should consider it.


No, if it lets you get around SOP then its a security flaw and should
*not* be considered.
It interferes with trying to teach proper OO concepts,

On the contrary. It teaches that an object has a value and still more
properties.


No it doesn't. It teaches people bad habits by not learning what is
underlying and relying on the browser to handle it.
and leads to statements like "JavaScript supports associative arrays"
because the concept of objects, properties and methods becomes hazy
and meaningless.

I think if people want to have misconceptions, there is no way talking
them out of them.


No, but, you *can* keep from propogating mis-understandings.

For the sake of 5 characters,

.... and another lookup operation probably reducing efficiency ...


That lookup has to happen either way. It's probably quicker to use .href
because then the browser doesn't have to guess what to do with the
string, the author has already told it.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #8
Randy Webb wrote:
Thomas 'PointedEars' Lahn wrote:
"Grant Wagner" schrieb:
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote [...]
"Grant Wagner" schrieb:
> It's window.location.href (or simply location.href).
Or even more simple `location' :)
I don't like assigning a String value to a Location object, no matter
what the underlying implementation does for me and I think it was a
mistake to implement it that way.

Well, using `location' instead of `location.href' workarounds the
Same Origin Policy by design, so you really should consider it.


No, if it lets you get around SOP then its a security flaw and should
*not* be considered.


Rubbish. That behaviour is by design, as you could have read in the
Netscape JavaScript Reference. But then your other statements clearly
mark you as incompetent in the matter.
PointedEars
Jul 23 '05 #9
Thomas 'PointedEars' Lahn wrote:
Randy Webb wrote:

Thomas 'PointedEars' Lahn wrote:
"Grant Wagner" schrieb:

"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote [...]

>"Grant Wagner" schrieb:
>
>>It's window.location.href (or simply location.href).
>
>Or even more simple `location' :)

I don't like assigning a String value to a Location object, no matter
what the underlying implementation does for me and I think it was a
mistake to implement it that way.

Well, using `location' instead of `location.href' workarounds the
Same Origin Policy by design, so you really should consider it.


No, if it lets you get around SOP then its a security flaw and should
*not* be considered.

Rubbish. That behaviour is by design, as you could have read in the
Netscape JavaScript Reference.


So now you are referring to a documentation that is where?

And which NS browser does it Reference?

And, if *any* browser lets a page have access to the location property
from a different origin that is a security flaw. Thats not
documentation, thats plain common sense.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #10
Randy Webb wrote:
Thomas 'PointedEars' Lahn wrote: <snip>
Well, using `location' instead of `location.href'
workarounds the Same Origin Policy by design,
so you really should consider it.

<snip> And, if *any* browser lets a page have access to the location
property from a different origin that is a security flaw.
Thats not documentation, thats plain common sense.


I think the point is that you don't need access to the - location -
object in order to assign to a - location - property of a window
object, only to the window object itself, while assigning to -
location.href - would require access to the location object (location
must be resolved as an object prior to assigning a property to it).

In a frame buster script a test along the lines of - if(self == top) -
demonstrates that you can have read access to the - top - object
(cross-domain scripts may resolve - top - as an object), even if it is a
different frame, from a different domain. It would be a security issue
if you could read the location object (say, calling its toString method
(even implicitly) to find the URL). It would also be a security issue if
you could read from - top.document - and any number of other properties
of - top-. But there is no security issue in assigning values to (at
least a few) properties of - top - as that would only replace the
original with something that you already know about, and render the
original completely inaccessible.

Obviously the issue is very much restricted to frame busting type
scripts.

Richard.
Jul 23 '05 #11
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message
news:42***********************@newsread4.arcor-online.net...
"Grant Wagner" schrieb:
It interferes with trying to teach proper OO concepts,


On the contrary. It teaches that an object has a value and still more
properties.


Except it the Location object doesn't have a value.

The implementation described by Netscape's documentation <url:
http://docs.sun.com/source/816-6408-10/location.htm />:

If you assign a string to the location property of an object, JavaScript
creates a location object and assigns that string to its href property.
For example, the following two statements are equivalent and set the URL
of the current window to the Netscape home page:

window.location.href="http://home.netscape.com/"window.location="http://home.netscape.com/"So
in at least one browser:

window.location = 'url';

is:

var s = 'url';
window.location = new Location();
window.location.href = s;

I don't see how hiding this fact helps anyone.

window.location contains a reference to a Location object, the Location
object has no value, it has properties. If you assign a string to the
window.location property containing the Location object reference, the
browser waves it's hands, says a magical incarnation and assigns that
string to the href property of a Location object referred to by
window.location.

This all has the madness of default properties in VisualBasic.
For the sake of 5 characters,


... and another lookup operation probably reducing efficiency ...


1) the inefficiency is negligible
2) if the description in the Netscape documentation is anywhere close to
accurate, assigning a string to the location property of the window
object actually involves _more_ work.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #12
On Thu, 26 May 2005 18:49:31 GMT, "Grant Wagner"
<gw*****@agricoreunited.com> wrote:
window.location contains a reference to a Location object, the Location
object has no value, it has properties. If you assign a string to the
window.location property containing the Location object reference, the
browser waves it's hands, says a magical incarnation and assigns that
string to the href property of a Location object referred to by
window.location.


Which is hardly unusual behaviour in programming languages.

int i=0;
Integer int=i;

is expanded exactly the same in Java 1.5 for example.
Jim.
Jul 23 '05 #13
"Jim Ley" <ji*@jibbering.com> wrote in message
news:42****************@news.individual.net...
On Thu, 26 May 2005 18:49:31 GMT, "Grant Wagner"
<gw*****@agricoreunited.com> wrote:
window.location contains a reference to a Location object, the
Location
object has no value, it has properties. If you assign a string to the
window.location property containing the Location object reference, the
browser waves it's hands, says a magical incarnation and assigns that
string to the href property of a Location object referred to by
window.location.


Which is hardly unusual behaviour in programming languages.

int i=0;
Integer int=i;

is expanded exactly the same in Java 1.5 for example.


Agreed, but in languages that support such "shortcuts" the behaviour is
consistent and documented.

Although it could be argued that location = 'url'; is documented, it
isn't consistent with the rest of the language. Then again, Location is
a host object, so I suppose it's allowed to play however it wants.

In the end it doesn't much matter what I think, location = 'url'; works
and I have to be prepared to read and understand code that makes use of
that syntax.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matt | last post by:
I want to disable the title bar, status bar and address bar of a window, but I couldn't find the syntax. I tried the following but not working. any ideas?? window.document.statusbar.enable =...
2
by: msnews.microsoft.com | last post by:
Hi All I m facing a problem. My Scenario is that i have a table in database with the name of "userprofile". In my web site the user enters his personal information for building his profile in...
8
by: Just D. | last post by:
Did anybody see the script to hide extra bars in the Internet Explorer? I'd like to start my WebApp with all these bars hidden. How? Thanks, Just D.
0
by: meh | last post by:
I am trying to use the web control. I have added the approiate reference and control to my project. I am using this code to make the addressbar , menubar, and toolbar show up... Dim ieBrowser...
1
by: GS | last post by:
I got a combobox box that I load at load time. the Item and vales ended up in reverse order of each other, what went wrong? the database table has the following row code value ebay ...
2
by: Lucky | last post by:
Hi guys, again with problem. now the problem is something like this. in the backend of the asp.net 2.0, i'm getting query string in the page_load event. the request url is something like this....
1
by: manuolive | last post by:
Hi Dudes, I have a query regarding browser url.Let me narrate the exact scenario which i need. I would like to expire my session when a person enters different url in the navigator bar...
0
by: mukeshrasm | last post by:
Hi I want to print the icon at address bar. I tried like this Code: ( html4strict ) <link rel=" SHORTCUT ICON" href="ch.ico" /> in the head section of HTML Tag. This image ch.ico is of...
6
by: davidson1 | last post by:
Hai friends... suppose if am browing MSN.com if i want that url should come to addressbar what i have to do.....so that nexttime without typing it..i can take from that..... can u help me
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.