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



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

但是,如果我想"重新加载"一个javascript应用程序呢?有没有办法这样做?谢谢!

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

在 JavaScript 中重新加载页面有 534 种不同的方法。任你挑选:

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();不起作用的地方起作用。

希望这有帮助! :)

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

如《使用 Java 和 JavaScript 构建混合 Android 应用程序》一书中所述 作者:Nizamettin Gok;尼廷·卡纳

这些应用以不同的视图持续运行同一页面,或者 内容,但不重新加载或导航到其他资源。这是通过将数据与表示层分离来实现的,并且严重依赖JavaScript。SPA 体系结构使用片段标识符,该标识符由 URL 位置中的井号标记 (#) 引入,后跟指向 HTML 文档中元素的锚点标识符。例如,如果您的网站网址如下所示 http://oreilly.com/index.html#article,则片段文章引用索引文档中具有 id="article" 属性.html HTML 元素。

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

JQuery Mobile:jQuery Mobile 页面刷新机制

科尔多瓦:如何在科尔多瓦项目上重新加载页面?

Ionic(angularJS):重新加载当前状态 - 刷新数据

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

相关内容

  • 没有找到相关文章

最新更新