php - Urls for results of Ajax requests -


Hi guys, I have developed a Google map application, which is a clean search feature - though I have seen that I want to Some people who Facebook friends have done as a hardlink to the page generated from the AJAX query. For example, you click on a link in Facebook and it engages in the current URL and you can paste the new URL to get the requested page ... How do I apply it ...

You can use location.hash (part of the URL after #) to set "hard link" with javascript This is not the reason for reloading the page, such as changing the location.href , but you can get the value and use it in javascript.

Consider this example:

  & lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 // N" "http://www.w3.org/TR/html4/strict.dtd"> & Lt; Top & gt; & Lt; Title & gt; Hash test & lt; / Title & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" & gt; & Lt; Script type = "text / javascript" & gt; Window.onload = function () {// Substring (1) #delete hash by var hash = window.location.hash.substring (1); // Use a default value if no one has passed (hash == '') {hash = 'nothing'; } // Use the value Document.getElementById ('Selection'). InnerHTML = hash; } / ** sets the hash and updates the page value * / function hash set (newHash) {window.location.hash = newHash; Document.getElementById ('Selection'). InnerHTML = newHash; } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div & gt; & Lt; Div & gt; & Lt; A href = "javascript: zero ();" Onclick = "Set hash ('Page 1');" & Gt; Page 1 & lt; / A & gt; | & Lt; A href = "javascript: zero ();" Onclick = "Set hash ('page 2');" & Gt; Page 2 & lt; / A & gt; | & Lt; A href = "javascript: zero ();" Onclick = "Set hash ('Page 3');" & Gt; Page 3 & lt; / A & gt; & Lt; / Div & gt; & Lt; Div & gt; You have chosen: & lt; Span id = "selection" & gt; ... & lt; / Span & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

When you click on a page link, the location.hash changes, the URL of the browser is updated and the value used in the page Has changed If the user copies the URL directly from the address bar, or bookmarks it, then the URL will be reloaded when the request is re-requested.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -