2017-04-06 12 views
0

デスクトップでは、location.reload();を使用できます。ページをリロードして、コードを再起動します。Location.reload()on mobile JS app

しかし、私はjavascriptアプリケーションを「再読み込み」したいのですが?そうする方法はありますか?ありがとう!

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

答えて

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モバイルアプリケーション(ハイブリッドモバイルアプリケーション)のアーキテクチャは、シングルページアプリケーションの概念に基づいています。

Nizamettin GokによるハイブリッドAndroidアプリのJavaおよびJavaScriptブック で説明したように、ニティンカンナ

これらのアプリは、永続的に異なるビューまたは コンテンツと同じページを実行しますが、リロードまたは別のresource.Thisに離れて移動することなくプレゼンテーション層からデータを分離することによって達成されるとJavaScriptに大きく依存しています。 SPAアーキテクチャーは、URLロケーションにハッシュタグ(#)で導入されたフラグメントIDを使用し、その後にHTML文書のエレメントを指すアンカーIDが続きます。たとえば、WebサイトのURLがhttp://oreilly.com/index.html#articleのように見える場合、フラグメント記事では、index.htmlドキュメントのid = "article"属性を持つHTML要素を参照しています。

したがって、ページをリロードすることは最良の選択ではないかもしれませんが、フレームワークに用意されているヘルパーを使用してこの問題を解決できます。ここではいくつかの例は以下のとおりです。

jQueryのモバイル:jQuery Mobile Page refresh mechanism

コルドバ:How to reload page on a Cordova project?

イオン(angularJS):Reloading current state - refresh data

ます。また、メソッドをデータバインディングを使用してビューを更新し、ページをリロード避けることができます。