0

I'm working on http://www.mapgrams.com/

My task at hand is to create a way to link to and from a specific popup. This way, people can share photos they like.

I'd like it so someone clicks a thumbnail, the popup opens and the url changes to mapgrams.com/645645345 or some other string.

Anyone have any ideas how to best implement this?

Also, here is the repo https://github.com/rsudekum/MapGrams

Thanks

bsudekum
  • 26
  • 1
  • 6
  • Are you asking how to update the URL without reloading the page like this: http://stackoverflow.com/questions/7077264/update-browsers-url-without-reloading-the-page or http://stackoverflow.com/questions/5525636/html-changing-the-url-without-reloading-the-page?rq=1 – jmbertucci Aug 06 '12 at 02:07

2 Answers2

1

To change the URL programmatically without refreshing the page, you can use a hash or you can use the HTML5 history API.

To change the hash, you just do

location.hash = 645645345;

which will change the URL to site.com/#645645345.

Using the HTML5 history API, you can do this:

history.pushState(null, "", "645645345");

which will change the URL to site.com/645645345.

Note that not all browsers (including IE<=9) support the HTML5 history API.

Peter Olson
  • 139,199
  • 49
  • 202
  • 242
0

https://github.com/browserstate/History.js/

I recommend the cross browser manager and pollyfill for history.pushstate. It uses html5 History api when available and hashchange where it is not. Good for deep linking as well as browser history control.

balupton
  • 47,113
  • 32
  • 131
  • 182
Fresheyeball
  • 29,567
  • 20
  • 102
  • 164