Skip to content

Instantly share code, notes, and snippets.

@7cc
Created November 20, 2013 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7cc/7570089 to your computer and use it in GitHub Desktop.
Save 7cc/7570089 to your computer and use it in GitHub Desktop.
reload if edit
!function(){
// http://javascripter.hatenablog.com/entry/20081103/1225682273
var last
(function check(){
var xhr = new XMLHttpRequest
var url = location.href
xhr.open("GET", url, true)
xhr.onload = function(){
if ( !last || last === xhr.response ) {
last = xhr.response
setTimeout(check, 1000);
}
else {
location.reload(true)
}
}
xhr.overrideMimeType('text\/plain; charset=x-user-defined');
xhr.send()
})()
}.call(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment