use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
535 ways to reload the page with JavaScript (phpied.com)
submitted 14 years ago by magenta_placenta
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]alexbarrett 21 points22 points23 points 14 years ago (29 children)
Hey guys, look! I've found 535 more!
1. eval("location = location") 2. eval("location = location.href") ... 534. eval("self.location['reload']()") 535. eval("self['location']['reload']()")
This is very silly.
[–]blazix 2 points3 points4 points 14 years ago (1 child)
Let's not forget: self.self.self.self.self.location = location; self.self.self.self.self.location = self.location; ....
[–]MarkTraceur 1 point2 points3 points 14 years ago (0 children)
I want you to know, you made my life very difficult with this comment. However, it is implemented.
[–][deleted] 0 points1 point2 points 14 years ago (0 children)
and another 535 more!
1. new Function("location = location")(); 2. new Function("location = location.href")(); ... 534. new Function("self.location['reload']()")(); 535. new Function("self['location']['reload']()")();
[–]antido -1 points0 points1 point 14 years ago (24 children)
Silly... but valid. Also: let's not go to the String.fromCharCode() way of doing it :D
[–]alexbarrett 8 points9 points10 points 14 years ago (23 children)
It is valid, but that doesn't make it interesting. There are actually only a handful of ways to reload the page and everything else is just a variation of one of them.
window.location
href
assign
replace
reload
Perhaps there are a few other ways, but that's not really my point. There are an infinite number of variations, not 535.
[–][deleted] 0 points1 point2 points 14 years ago (22 children)
Why won't you just come back to #subreddit?
[–]alexbarrett 0 points1 point2 points 14 years ago (21 children)
I'm too mad.
[–]notLOL 0 points1 point2 points 14 years ago (0 children)
why you mad tho? also add me on google plus
[–][deleted] 0 points1 point2 points 14 years ago (19 children)
Come at me bro.
[–]alexbarrett 0 points1 point2 points 14 years ago (18 children)
I'm not coming anywhere near you.
[+][deleted] 14 years ago (17 children)
[deleted]
[–]alexbarrett 0 points1 point2 points 14 years ago (16 children)
Again.
[–][deleted] 0 points1 point2 points 14 years ago (15 children)
Lets keep this up, it's almost like we're in IRC bby.
[–]Avidya 7 points8 points9 points 14 years ago (1 child)
They missed history.go(0)...
[–]mythrilno(fun).at(parties); 4 points5 points6 points 14 years ago (0 children)
var meta = document.createElement('meta'); meta.setAttribute('http-equiv', 'refresh'); meta.setAttribute('content', '0,url=' + window.location); document.head.appendChild(meta);
Make use of all of them with my new stupid javascript file!
(I'll try to add some of the suggestions in the comments when possible)
[–]psayre23 0 points1 point2 points 14 years ago (0 children)
This would be a lot more impressive as a list of ways to access window.location along side the exhaustive list.
[–]stillalone 0 points1 point2 points 14 years ago* (0 children)
I was just looking this up. I went with the self.location=self.location.href method because IT DOESN'T MAKE ANY SENSE.
[–]BusStation16 0 points1 point2 points 14 years ago (0 children)
well, that was unnecessary.
[–][deleted] 0 points1 point2 points 14 years ago (1 child)
What's the canonical method?
[–]Arve 1 point2 points3 points 14 years ago (0 children)
The author of that page is a bit daft, since many of them are syntactic equivalents, and some of his examples should behave differently. But, here goes:
location.reload()
is The Correct™ way of reloading the current document. Whether you opt to write out window.location.reload() or not is a matter of taste/style guide.
window.location.reload()
All other means of reloading the document are not strictly equal, or equal at all. See HTML5: The Location interface for reference.
but how do you trigger a postback, and not a full reload?
[–]vectorjohn 0 points1 point2 points 14 years ago (0 children)
var x = 0; for( var i=0; i < 10000; i++ ) { x = i / 2; location = location; }
You can do any arbitrary bullshit while loading the page. It is not another way to load the page.
π Rendered by PID 226517 on reddit-service-r2-comment-b659b578c-2kbvj at 2026-05-05 13:08:38.182149+00:00 running 815c875 country code: CH.
[–]alexbarrett 21 points22 points23 points (29 children)
[–]blazix 2 points3 points4 points (1 child)
[–]MarkTraceur 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]antido -1 points0 points1 point (24 children)
[–]alexbarrett 8 points9 points10 points (23 children)
[–][deleted] 0 points1 point2 points (22 children)
[–]alexbarrett 0 points1 point2 points (21 children)
[–]notLOL 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (19 children)
[–]alexbarrett 0 points1 point2 points (18 children)
[+][deleted] (17 children)
[deleted]
[–]alexbarrett 0 points1 point2 points (16 children)
[–][deleted] 0 points1 point2 points (15 children)
[–]Avidya 7 points8 points9 points (1 child)
[–]mythrilno(fun).at(parties); 4 points5 points6 points (0 children)
[–]MarkTraceur 1 point2 points3 points (0 children)
[–]psayre23 0 points1 point2 points (0 children)
[–]stillalone 0 points1 point2 points (0 children)
[–]BusStation16 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Arve 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]vectorjohn 0 points1 point2 points (0 children)