Skip to content Skip to sidebar Skip to footer

Location.reload() On Mobile Js App

On a desktop, you can use location.reload(); and it will reload the page, restarting the code on it. But what if I wanted to 'reload' a javascript app? Is there a way to do so? Tha

Solution 1:

There's 534 different ways to reload a page in JavaScript. Take your pick:

location = location
location = location.href
location = window.location
location = self.location
location = window.location.href
location = self.location.href
location = location['href']
location = window['location']
location = window['location'].href
location = window['location']['href']
location = window.location['href']
location = self['location']
location = self['location'].href
location = self['location']['href']
location = self.location['href']
location.assign(location)
location.replace(location)
window.location.assign(location)
window.location.replace(location)
self.location.assign(location)
self.location.replace(location)
location['assign'](location)
location['replace'](location)
window.location['assign'](location)
window.location['replace'](location)
window['location'].assign(location)
window['location'].replace(location)
window['location']['assign'](location)
window['location']['replace'](location)
self.location['assign'](location)
self.location['replace'](location)
self['location'].assign(location)
self['location'].replace(location)
self['location']['assign'](location)
self['location']['replace'](location)
location.href = location
location.href = location.href
location.href = window.location
location.href = self.location
location.href = window.location.href
location.href = self.location.href
location.href = location['href']
location.href = window['location']
location.href = window['location'].href
location.href = window['location']['href']
location.href = window.location['href']
location.href = self['location']
location.href = self['location'].href
location.href = self['location']['href']
location.href = self.location['href']
location.assign(location.href)
location.replace(location.href)
window.location.assign(location.href)
window.location.replace(location.href)
self.location.assign(location.href)
self.location.replace(location.href)
location['assign'](location.href)
location['replace'](location.href)
window.location['assign'](location.href)
window.location['replace'](location.href)
window['location'].assign(location.href)
window['location'].replace(location.href)
window['location']['assign'](location.href)
window['location']['replace'](location.href)
self.location['assign'](location.href)
self.location['replace'](location.href)
self['location'].assign(location.href)
self['location'].replace(location.href)
self['location']['assign'](location.href)
self['location']['replace'](location.href)
window.location = location
window.location = location.href
window.location = window.location
window.location = self.location
window.location = window.location.href
window.location = self.location.href
window.location = location['href']
window.location = window['location']
window.location = window['location'].href
window.location = window['location']['href']
window.location = window.location['href']
window.location = self['location']
window.location = self['location'].href
window.location = self['location']['href']
window.location = self.location['href']
location.assign(window.location)
location.replace(window.location)
window.location.assign(window.location)
window.location.replace(window.location)
self.location.assign(window.location)
self.location.replace(window.location)
location['assign'](window.location)
location['replace'](window.location)
window.location['assign'](window.location)
window.location['replace'](window.location)
window['location'].assign(window.location)
window['location'].replace(window.location)
window['location']['assign'](window.location)
window['location']['replace'](window.location)
self.location['assign'](window.location)
self.location['replace'](window.location)
self['location'].assign(window.location)
self['location'].replace(window.location)
self['location']['assign'](window.location)
self['location']['replace'](window.location)
self.location = location
self.location = location.href
self.location = window.location
self.location = self.location
self.location = window.location.href
self.location = self.location.href
self.location = location['href']
self.location = window['location']
self.location = window['location'].href
self.location = window['location']['href']
self.location = window.location['href']
self.location = self['location']
self.location = self['location'].href
self.location = self['location']['href']
self.location = self.location['href']
location.assign(self.location)
location.replace(self.location)
window.location.assign(self.location)
window.location.replace(self.location)
self.location.assign(self.location)
self.location.replace(self.location)
location['assign'](self.location)
location['replace'](self.location)
window.location['assign'](self.location)
window.location['replace'](self.location)
window['location'].assign(self.location)
window['location'].replace(self.location)
window['location']['assign'](self.location)
window['location']['replace'](self.location)
self.location['assign'](self.location)
self.location['replace'](self.location)
self['location'].assign(self.location)
self['location'].replace(self.location)
self['location']['assign'](self.location)
self['location']['replace'](self.location)
window.location.href = location
window.location.href = location.href
window.location.href = window.location
window.location.href = self.location
window.location.href = window.location.href
window.location.href = self.location.href
window.location.href = location['href']
window.location.href = window['location']
window.location.href = window['location'].href
window.location.href = window['location']['href']
window.location.href = window.location['href']
window.location.href = self['location']
window.location.href = self['location'].href
window.location.href = self['location']['href']
window.location.href = self.location['href']
location.assign(window.location.href)
location.replace(window.location.href)
window.location.assign(window.location.href)
window.location.replace(window.location.href)
self.location.assign(window.location.href)
self.location.replace(window.location.href)
location['assign'](window.location.href)
location['replace'](window.location.href)
window.location['assign'](window.location.href)
window.location['replace'](window.location.href)
window['location'].assign(window.location.href)
window['location'].replace(window.location.href)
window['location']['assign'](window.location.href)
window['location']['replace'](window.location.href)
self.location['assign'](window.location.href)
self.location['replace'](window.location.href)
self['location'].assign(window.location.href)
self['location'].replace(window.location.href)
self['location']['assign'](window.location.href)
self['location']['replace'](window.location.href)
self.location.href = location
self.location.href = location.href
self.location.href = window.location
self.location.href = self.location
self.location.href = window.location.href
self.location.href = self.location.href
self.location.href = location['href']
self.location.href = window['location']
self.location.href = window['location'].href
self.location.href = window['location']['href']
self.location.href = window.location['href']
self.location.href = self['location']
self.location.href = self['location'].href
self.location.href = self['location']['href']
self.location.href = self.location['href']
location.assign(self.location.href)
location.replace(self.location.href)
window.location.assign(self.location.href)
window.location.replace(self.location.href)
self.location.assign(self.location.href)
self.location.replace(self.location.href)
location['assign'](self.location.href)
location['replace'](self.location.href)
window.location['assign'](self.location.href)
window.location['replace'](self.location.href)
window['location'].assign(self.location.href)
window['location'].replace(self.location.href)
window['location']['assign'](self.location.href)
window['location']['replace'](self.location.href)
self.location['assign'](self.location.href)
self.location['replace'](self.location.href)
self['location'].assign(self.location.href)
self['location'].replace(self.location.href)
self['location']['assign'](self.location.href)
self['location']['replace'](self.location.href)
location['href'] = location
location['href'] = location.href
location['href'] = window.location
location['href'] = self.location
location['href'] = window.location.href
location['href'] = self.location.href
location['href'] = location['href']
location['href'] = window['location']
location['href'] = window['location'].href
location['href'] = window['location']['href']
location['href'] = window.location['href']
location['href'] = self['location']
location['href'] = self['location'].href
location['href'] = self['location']['href']
location['href'] = self.location['href']
location.assign(location['href'])
location.replace(location['href'])
window.location.assign(location['href'])
window.location.replace(location['href'])
self.location.assign(location['href'])
self.location.replace(location['href'])
location['assign'](location['href'])
location['replace'](location['href'])
window.location['assign'](location['href'])
window.location['replace'](location['href'])
window['location'].assign(location['href'])
window['location'].replace(location['href'])
window['location']['assign'](location['href'])
window['location']['replace'](location['href'])
self.location['assign'](location['href'])
self.location['replace'](location['href'])
self['location'].assign(location['href'])
self['location'].replace(location['href'])
self['location']['assign'](location['href'])
self['location']['replace'](location['href'])
window['location'] = location
window['location'] = location.href
window['location'] = window.location
window['location'] = self.location
window['location'] = window.location.href
window['location'] = self.location.href
window['location'] = location['href']
window['location'] = window['location']
window['location'] = window['location'].href
window['location'] = window['location']['href']
window['location'] = window.location['href']
window['location'] = self['location']
window['location'] = self['location'].href
window['location'] = self['location']['href']
window['location'] = self.location['href']
location.assign(window['location'])
location.replace(window['location'])
window.location.assign(window['location'])
window.location.replace(window['location'])
self.location.assign(window['location'])
self.location.replace(window['location'])
location['assign'](window['location'])
location['replace'](window['location'])
window.location['assign'](window['location'])
window.location['replace'](window['location'])
window['location'].assign(window['location'])
window['location'].replace(window['location'])
window['location']['assign'](window['location'])
window['location']['replace'](window['location'])
self.location['assign'](window['location'])
self.location['replace'](window['location'])
self['location'].assign(window['location'])
self['location'].replace(window['location'])
self['location']['assign'](window['location'])
self['location']['replace'](window['location'])
window['location'].href = location
window['location'].href = location.href
window['location'].href = window.location
window['location'].href = self.location
window['location'].href = window.location.href
window['location'].href = self.location.href
window['location'].href = location['href']
window['location'].href = window['location']
window['location'].href = window['location'].href
window['location'].href = window['location']['href']
window['location'].href = window.location['href']
window['location'].href = self['location']
window['location'].href = self['location'].href
window['location'].href = self['location']['href']
window['location'].href = self.location['href']
location.assign(window['location'].href)
location.replace(window['location'].href)
window.location.assign(window['location'].href)
window.location.replace(window['location'].href)
self.location.assign(window['location'].href)
self.location.replace(window['location'].href)
location['assign'](window['location'].href)
location['replace'](window['location'].href)
window.location['assign'](window['location'].href)
window.location['replace'](window['location'].href)
window['location'].assign(window['location'].href)
window['location'].replace(window['location'].href)
window['location']['assign'](window['location'].href)
window['location']['replace'](window['location'].href)
self.location['assign'](window['location'].href)
self.location['replace'](window['location'].href)
self['location'].assign(window['location'].href)
self['location'].replace(window['location'].href)
self['location']['assign'](window['location'].href)
self['location']['replace'](window['location'].href)
window['location']['href'] = location
window['location']['href'] = location.href
window['location']['href'] = window.location
window['location']['href'] = self.location
window['location']['href'] = window.location.href
window['location']['href'] = self.location.href
window['location']['href'] = location['href']
window['location']['href'] = window['location']
window['location']['href'] = window['location'].href
window['location']['href'] = window['location']['href']
window['location']['href'] = window.location['href']
window['location']['href'] = self['location']
window['location']['href'] = self['location'].href
window['location']['href'] = self['location']['href']
window['location']['href'] = self.location['href']
location.assign(window['location']['href'])
location.replace(window['location']['href'])
window.location.assign(window['location']['href'])
window.location.replace(window['location']['href'])
self.location.assign(window['location']['href'])
self.location.replace(window['location']['href'])
location['assign'](window['location']['href'])
location['replace'](window['location']['href'])
window.location['assign'](window['location']['href'])
window.location['replace'](window['location']['href'])
window['location'].assign(window['location']['href'])
window['location'].replace(window['location']['href'])
window['location']['assign'](window['location']['href'])
window['location']['replace'](window['location']['href'])
self.location['assign'](window['location']['href'])
self.location['replace'](window['location']['href'])
self['location'].assign(window['location']['href'])
self['location'].replace(window['location']['href'])
self['location']['assign'](window['location']['href'])
self['location']['replace'](window['location']['href'])
window.location['href'] = location
window.location['href'] = location.href
window.location['href'] = window.location
window.location['href'] = self.location
window.location['href'] = window.location.href
window.location['href'] = self.location.href
window.location['href'] = location['href']
window.location['href'] = window['location']
window.location['href'] = window['location'].href
window.location['href'] = window['location']['href']
window.location['href'] = window.location['href']
window.location['href'] = self['location']
window.location['href'] = self['location'].href
window.location['href'] = self['location']['href']
window.location['href'] = self.location['href']
location.assign(window.location['href'])
location.replace(window.location['href'])
window.location.assign(window.location['href'])
window.location.replace(window.location['href'])
self.location.assign(window.location['href'])
self.location.replace(window.location['href'])
location['assign'](window.location['href'])
location['replace'](window.location['href'])
window.location['assign'](window.location['href'])
window.location['replace'](window.location['href'])
window['location'].assign(window.location['href'])
window['location'].replace(window.location['href'])
window['location']['assign'](window.location['href'])
window['location']['replace'](window.location['href'])
self.location['assign'](window.location['href'])
self.location['replace'](window.location['href'])
self['location'].assign(window.location['href'])
self['location'].replace(window.location['href'])
self['location']['assign'](window.location['href'])
self['location']['replace'](window.location['href'])
self['location'] = location
self['location'] = location.href
self['location'] = window.location
self['location'] = self.location
self['location'] = window.location.href
self['location'] = self.location.href
self['location'] = location['href']
self['location'] = window['location']
self['location'] = window['location'].href
self['location'] = window['location']['href']
self['location'] = window.location['href']
self['location'] = self['location']
self['location'] = self['location'].href
self['location'] = self['location']['href']
self['location'] = self.location['href']
location.assign(self['location'])
location.replace(self['location'])
window.location.assign(self['location'])
window.location.replace(self['location'])
self.location.assign(self['location'])
self.location.replace(self['location'])
location['assign'](self['location'])
location['replace'](self['location'])
window.location['assign'](self['location'])
window.location['replace'](self['location'])
window['location'].assign(self['location'])
window['location'].replace(self['location'])
window['location']['assign'](self['location'])
window['location']['replace'](self['location'])
self.location['assign'](self['location'])
self.location['replace'](self['location'])
self['location'].assign(self['location'])
self['location'].replace(self['location'])
self['location']['assign'](self['location'])
self['location']['replace'](self['location'])
self['location'].href = location
self['location'].href = location.href
self['location'].href = window.location
self['location'].href = self.location
self['location'].href = window.location.href
self['location'].href = self.location.href
self['location'].href = location['href']
self['location'].href = window['location']
self['location'].href = window['location'].href
self['location'].href = window['location']['href']
self['location'].href = window.location['href']
self['location'].href = self['location']
self['location'].href = self['location'].href
self['location'].href = self['location']['href']
self['location'].href = self.location['href']
location.assign(self['location'].href)
location.replace(self['location'].href)
window.location.assign(self['location'].href)
window.location.replace(self['location'].href)
self.location.assign(self['location'].href)
self.location.replace(self['location'].href)
location['assign'](self['location'].href)
location['replace'](self['location'].href)
window.location['assign'](self['location'].href)
window.location['replace'](self['location'].href)
window['location'].assign(self['location'].href)
window['location'].replace(self['location'].href)
window['location']['assign'](self['location'].href)
window['location']['replace'](self['location'].href)
self.location['assign'](self['location'].href)
self.location['replace'](self['location'].href)
self['location'].assign(self['location'].href)
self['location'].replace(self['location'].href)
self['location']['assign'](self['location'].href)
self['location']['replace'](self['location'].href)
self['location']['href'] = location
self['location']['href'] = location.href
self['location']['href'] = window.location
self['location']['href'] = self.location
self['location']['href'] = window.location.href
self['location']['href'] = self.location.href
self['location']['href'] = location['href']
self['location']['href'] = window['location']
self['location']['href'] = window['location'].href
self['location']['href'] = window['location']['href']
self['location']['href'] = window.location['href']
self['location']['href'] = self['location']
self['location']['href'] = self['location'].href
self['location']['href'] = self['location']['href']
self['location']['href'] = self.location['href']
location.assign(self['location']['href'])
location.replace(self['location']['href'])
window.location.assign(self['location']['href'])
window.location.replace(self['location']['href'])
self.location.assign(self['location']['href'])
self.location.replace(self['location']['href'])
location['assign'](self['location']['href'])
location['replace'](self['location']['href'])
window.location['assign'](self['location']['href'])
window.location['replace'](self['location']['href'])
window['location'].assign(self['location']['href'])
window['location'].replace(self['location']['href'])
window['location']['assign'](self['location']['href'])
window['location']['replace'](self['location']['href'])
self.location['assign'](self['location']['href'])
self.location['replace'](self['location']['href'])
self['location'].assign(self['location']['href'])
self['location'].replace(self['location']['href'])
self['location']['assign'](self['location']['href'])
self['location']['replace'](self['location']['href'])
self.location['href'] = location
self.location['href'] = location.href
self.location['href'] = window.location
self.location['href'] = self.location
self.location['href'] = window.location.href
self.location['href'] = self.location.href
self.location['href'] = location['href']
self.location['href'] = window['location']
self.location['href'] = window['location'].href
self.location['href'] = window['location']['href']
self.location['href'] = window.location['href']
self.location['href'] = self['location']
self.location['href'] = self['location'].href
self.location['href'] = self['location']['href']
self.location['href'] = self.location['href']
location.assign(self.location['href'])
location.replace(self.location['href'])
window.location.assign(self.location['href'])
window.location.replace(self.location['href'])
self.location.assign(self.location['href'])
self.location.replace(self.location['href'])
location['assign'](self.location['href'])
location['replace'](self.location['href'])
window.location['assign'](self.location['href'])
window.location['replace'](self.location['href'])
window['location'].assign(self.location['href'])
window['location'].replace(self.location['href'])
window['location']['assign'](self.location['href'])
window['location']['replace'](self.location['href'])
self.location['assign'](self.location['href'])
self.location['replace'](self.location['href'])
self['location'].assign(self.location['href'])
self['location'].replace(self.location['href'])
self['location']['assign'](self.location['href'])
self['location']['replace'](self.location['href'])
location.reload()
location['reload']()
window.location.reload()
window['location'].reload()
window.location['reload']()
window['location']['reload']()
self.location.reload()
self['location'].reload()
self.location['reload']()
self['location']['reload']()

One of those is bound to work where location.reload(); doesn't.

Hope this helps! :)

Solution 2:

The architecture of most of JS mobile applications (Hybrid Mobile Applications) is based on the concept of single page application.

As mentioned in Building Hybrid Android Apps with Java and JavaScript Book by Nizamettin Gok; Nitin Khanna

These apps persistently run the same page with different views or content, but without reloading or navigating away to another resource.This is achieved by separating the data from the presentation layer and relies heavily on JavaScript. SPA architecture uses the fragment identifier, which is introduced by a hashtag (#) in the URL location, followed by an anchor identifier to point to an element in the HTML document. For example, if your website URL looks like this http://oreilly.com/index.html#article, The fragment article refers to an HTML element with an id="article" attribute in the index.html document.

So the idea of reloading the page may not be the best choice but however you can overcome this problem using the helpers provided on your framework. Here are some examples:

JQuery Mobile: jQuery Mobile Page refresh mechanism

Cordova: How to reload page on a Cordova project?

Ionic(angularJS): Reloading current state - refresh data

You can also update the view using the data binding methods and avoid reloading the page.

Post a Comment for "Location.reload() On Mobile Js App"