![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]() |

|
| Programming tutorials All Knowledge Info and links to posted here |
![]() |
|
Javascript location Object explained
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Administrator
Posts: 18,715
Join Date: Jan 2006
Rep Power: 10
IM:
|
Location object stores information about the current URL in the window. For example a statement: window.location.href = "http://www.bewebmaster.com"; loads BeWebmaster website in the current browser window. The href property contains the entire URL, but you can use various properties to access portions of the URL. Properties Let's take following URL apart: http://www.bewebmaster.com:80/55.php?id=12#headline
The location object has two methods: location.reload()- reloads the current page. It acts the same as the browser reload button. You can include a parameter true to ignore the browser's cache and force a reload whether the document has changed or not. location.replace()- replaces the current location with a new one. It's pretty much the same as changing the location properties, except that it doesn't affect the browser's history. So, if you use replace method you can't use browser's back button to go to previous location. This is mostly used for temporary pages or splash screens. Example Let's say you are using an AJAX script to load a page based on the search query in the URL. You could create a function: function getSearch() { return document.location.search; } or just use document.location.search somewhere within the function that handles AJAX calls. If you want to pass a url to the function above you can modify above code to. function getSearch(url) { return url.location.search; } and call it like this: <a href="javascript:getSearch(this.document);">Pass a URL</a> |
|
|
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FlippingBook SWF Object 1.8.8 | SlimShady | Application Downloads | 0 | 05-Apr-2008 11:28 AM |
| Move the Object using the arrow keys | Anilrgowda | Graphic tutorials | 0 | 27-Feb-2007 02:11 AM |
| Error Locating Object Handler | Anilrgowda | Internet Explorer Error | 0 | 29-Jan-2007 09:59 AM |
| Group Policy Object Editor in vista | Anilrgowda | Microsoft windows vista error | 0 | 29-Jan-2007 06:57 AM |
| Object Oriented Programming in Java | Anilrgowda | Programming tutorials | 0 | 21-Dec-2006 02:01 AM |