移动JS应用程序上的Location.reload()

时间:2017-04-06 23:59:22

标签: javascript mobile reload desktop

在桌面上,您可以使用location.reload();,它会重新加载页面,重新启动代码。

但是,如果我想“重新加载”一个javascript应用程序呢?有办法吗?谢谢!

location.reload();
// Page reloads on desktop, app does nothing on mobile

2 个答案:

答案 0 :(得分:3)

使用JavaScript重新加载页面534 different ways。请选择:

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']()

其中一个必然会在location.reload();没有的地方工作。

希望这有帮助! :)

答案 1 :(得分:1)

大多数JS移动应用程序(混合移动应用程序)的架构都基于单页面应用程序的概念。

如使用Java和JavaScript Book构建混合Android应用程序中所述 作者:Nizamettin Gok; Nitin Khanna

  

这些应用程序持续运行具有不同视图的同一页面或   内容,但没有重新加载或导航到另一个资源。这是通过从表示层分离数据并严重依赖JavaScript来实现的。 SPA体系结构使用片段标识符,该标识符由URL位置中的#标签引入,后跟锚标识符以指向HTML文档中的元素。例如,如果您的网站网址类似于此http://oreilly.com/index.html#article,则片段文章引用index.html文档中具有id =“article”属性的HTML元素。

因此,重新加载页面的想法可能不是最佳选择,但是您可以使用框架上提供的帮助程序克服此问题。以下是一些例子:

JQuery Mobile:jQuery Mobile Page refresh mechanism

科尔多瓦:How to reload page on a Cordova project?

离子(angularJS):Reloading current state - refresh data

您还可以使用数据绑定方法更新视图,避免重新加载页面。