Click to See Complete Forum and Search --> : How do I Get the value of the browsers Address Bar
jgestrella
10-21-2003, 11:53 PM
How can I get the value of the Browsers Address Bar?
Hope you can help me out. Please feel free to email me at jgestrella@bpi.com.ph
Thanks!
fredmv
10-22-2003, 12:06 AM
The property you are looking for is location.href. Here's a simple example that prints the current URL:<script type="text/javascript">
document.writeln( location.href );
</script>I hope that helps you out.
jgestrella
10-22-2003, 12:23 AM
thanks for the help, i did try this out but this is not what i need because this returns the server host name. I need to get the actual value of the clients browser address bar. For example, There are 2 sites, www.site1.com and www.site2.com.
www.site1.com can be accessed to launch www.site2.com. If I use the code you gave to get the value in www.site2.com, it will return www.site2.com.
Thanks again.
jghoward
01-13-2008, 04:00 PM
The property you are looking for is location.href. Here's a simple example that prints the current URL:<script type="text/javascript">
document.writeln( location.href );
</script>I hope that helps you out.
This might potentially help me out a lot. I want to parse the full URL of a search results page and then use this url as the SRC of an iFrame within the same page (adding an extra variable that will load a google map in the iframe)
I incorrectly tried using your code like
(http://www.webdeveloper.com/forum/misc.php?do=bbcode#code)iframe src="<script type="text/javascript">document.writeln( location.href );"</script> (http://www.webdeveloper.com/forum/misc.php?do=bbcode#code)
What is the correct way to use this to get my iframe working?
Thank You so Much if you can help, I'm new to Javascript and trying to learn by example.
Killzone_Kid
01-13-2008, 05:02 PM
Try:
<script>document.write('<iframe src="'+document.location+'"></iframe>');</script>
Arty Effem
01-13-2008, 05:32 PM
thanks for the help, i did try this out but this is not what i need because this returns the server host name. I need to get the actual value of the clients browser address bar. For example, There are 2 sites, www.site1.com and www.site2.com.
www.site1.com can be accessed to launch www.site2.com. If I use the code you gave to get the value in www.site2.com, it will return www.site2.com.
Thanks again.Are you saying that you want to get the URL of a search results page, that generated a link that was used to access your page?
jghoward
01-14-2008, 12:23 AM
I tried it like this:
<div id="map_canvas"><script>document.write('<iframe src="'+document.location+'" width="372" height="248" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" title="This is an iframe containing a Google Map"></iframe>');</script></div>
but it's not loading the map. Do you see anything wrong in that code snippet? From what I have read, it does look like +document.location+ should work. Thanks.
EDITED!: SUCCESS
I forgot to add the bit I wanted to the URL that specifies my map template. Now it's working perfectly. Thank You so Much!! You wouldn't believe how long I have searched for a simple solution like this.
jghoward
01-14-2008, 12:37 AM
I probably should not have mentioned search results. To be more specific, though- My Search Results page is produced by a cgi script running on my own server. It produces a URL full of the search parameters that looks like this:
http://www.mydomain.com/search.cgi?template=template1&search=1&perpage=10&sort_order=5%2C123%2Cforward&SUBMIT=Search
What I need to do is somehow grab this URL, add an extra bit (&maptemplate=x) and call it from an iframe within this same page. This should resubmit my search and load the results displayed as marked locations on a google map. The map is in an iframe at the top of the page. Below the iframe are the same search results, only represented as text descriptions. Hope what Im doing makes sense.