location=location

location = location
... and 534 other ways to reload the page with JavaScript

How many ways you can think of when you want to reload the current page with JavaScript? I counted 535 before I got bored, maybe someone can pick up from there? The cases are so much that I had to write a script to generate them :)

» have fun, see for yourself

Just occurred to me that I didn't even include the frames property in those 535 ways. Consider the limitless possibilities having in mind for example that:

>>> window.frames === window
true
>>> frames === window.self
true

Could you come up with 500 more ways? A 1000? One condition: no recursion, for example window.self.window is not allowed.

Bookmark and Share

Somewhat related posts

7 Responses to “location=location”

  1. BoĊĦtjan Says:

    Ha ha, you must have had lots of time :)

  2. ken Says:

    Missed all the ones using “this” :)

  3. jax Says:

    Would you accept things like:

    document.forms[0].reset;document.forms[0].action=’/';document.forms[0].submit();

    It isn’t quite a “reload”, but (depending how you got there) is is the same.

    Also, didn’t scan the whole list, but did you include: history.go(0); ?

  4. Stoyan Says:

    Ken, true, but this may have a different value depending on the context, it’s not necessarily synonymous to window

  5. Javascript News » Blog Archive » 535 ways to reload the page with JavaScript Says:

    [...] And according to the blog post (http://www.phpied.com/locationlocation/), this is probably only the beginning. Ah, some people just have too much time on their hands [...]

  6. Philip Says:

    there’s also document.location and window.frames.location, and then you can also use document.documentURI or document.URL as the rvalue for your assignment.

    Then, you can get to the document object using window.parent.document (if it is not in an iframe)

  7. Stoyan Says:

    @jax - I think I missed history.go(), thanks

    @Philip, good ones, also maybe window.top?

Leave a Reply