Skip to content

Instantly share code, notes, and snippets.

@masahitojp
Created July 18, 2011 15:58
Show Gist options
  • Save masahitojp/1089937 to your computer and use it in GitHub Desktop.
Save masahitojp/1089937 to your computer and use it in GitHub Desktop.
// 今開いてるページに変更があったらリロード
var ypos = location.hash.replace(/^[#]/,"");
(!!ypos && (typeof ypos === "number"))&&window.scroll(0,ypos);
setInterval(function(){
var self = arguments.callee;
var req = new XMLHttpRequest;
req.open("GET",location.href,true);
req.onload = function(){
(self.old && req.responseText != self.old) && location.replace(location.href.replace(/[#].*$/,"") + "#" + document.documentElement.scrollTop);
self.old = req.responseText;
};
req.send(null);
},1000);
<a href='javascript:location.href.indexOf("http")!=0%20?%20(function(){var%20t=document.title;document.write('<script>var ypos = location.hash.replace(/^[#]/,"");(!!ypos && (typeof ypos === "number"))&&window.scroll(0,ypos);setInterval(function(){var%20self%20=%20arguments.callee;var%20req%20=%20new%20XMLHttpRequest;req.open("GET","',prompt("trigger%20file",location.href),'",true);req.onload%20=%20function(){(self.old%20&&%20req.responseText%20!=%20self.old)%20&&%20window.doc.location.replace(window.doc.location.href.replace(/[#].*$/,"") + "#" + window.doc.document.documentElement.scrollTop);self.old%20=%20req.responseText;};req.send(null)},1000)</script><frameset><frame%20name="doc"%20src="',location.href,'"></frame></frameset>');document.close();document.title=t})():alert("this%20is%20Not%20local%20file");'>Auto Reload</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment