{"id":1006,"date":"2012-06-17T23:06:14","date_gmt":"2012-06-17T14:06:14","guid":{"rendered":"https:\/\/ecoop.net\/memo\/?p=1006"},"modified":"2018-11-21T20:20:11","modified_gmt":"2018-11-21T11:20:11","slug":"webview-shouldoverrideurlloading-problem","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/webview-shouldoverrideurlloading-problem.html","title":{"rendered":"WebView\u3067shouldOverrideUrlLoading()\u304c\u53cd\u5fdc\u3057\u306a\u3044\u554f\u984c"},"content":{"rendered":"<p>StackOverflow\u3067\u3082&#8221;<a href=\"http:\/\/stackoverflow.com\/questions\/5228926\/shouldoverrideurlloading-not-executed-if-window-location-href-modified-in\">shouldOverrideUrlLoading(\u2026) not executed if \u201cwindow.location.href\u201d modified in a timeout callback<\/a>&#8220;\u3068\u5831\u544a\u3055\u308c\u3066\u3044\u308b\u304c\u3001WebView\u3067 JavaScript \u304b\u3089 location.href \u3092\u66f8\u304d\u63db\u3048\u308b\u3068\u901a\u5e38shouldOverrideUrlLoading()\u304c\u53cd\u5fdc\u3059\u308b\u306e\u306b setTimeout()\u3092\u4f7f\u7528\u3057\u3066 location.href \u3092\u66f8\u304d\u63db\u3048\u305f\u5834\u5408\u306f shouldOverrideUrlLoading() \u304c\u547c\u3070\u308c\u307e\u305b\u3093\u3002<!--more-->\u305f\u3068\u3048\u3070\u3001\u4e0b\u8a18\u306egotoMainPage()\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u3063\u305f\u5834\u5408\u3001<br \/>\n[JavaScript]<br \/>\nfunction gotoMainPage( ) {<br \/>\n    window.location.href = &#8220;main\/main.do&#8221;;<br \/>\n}<br \/>\n[\/JavaScript]<br \/>\n\u901a\u5e38\u3001html\u306eonClick=&#8221;&#8221;\u304b\u3089gotoMainPage()\u3092\u5b9f\u884c\u3057\u305f\u5834\u5408\u306f shouldOverrideUrlLoading() \u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&amp;lt;!-- \u3053\u308c\u306f\u5927\u4e08\u592b --&amp;gt;\r\n&amp;lt;button onclick=&quot;gotoMainPage();&quot;&amp;gt;\r\n<\/pre>\n<p>\u3053\u308c\u3092setTimeout()\u3092\u7d4c\u7531\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u305f\u9014\u7aefshouldOverrideUrlLoading()\u304c\u5b9f\u884c\u3055\u308c\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&amp;lt;!-- \u3053\u308c\u3060\u3068shouldOverrideUrlLoading()\u304c\u52d5\u304b\u306a\u3044 --&amp;gt;\r\n&amp;lt;button onclick=&quot;setTimeout(gotoMainPage,100);&quot;&amp;gt;\r\n<\/pre>\n<p>setTimeout()\u3092\u4f7f\u3063\u305f\u5834\u5408\u3001\u3069\u3046\u3084\u3089Ajax\u306a\u3069\u3068\u540c\u69d8\u30e6\u30fc\u30b6\u624b\u52d5\u3067\u306a\u3044\u53c2\u7167\u3068\u307f\u306a\u3055\u308c\u3001\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u51e6\u7406\u3068\u3057\u3066\u5224\u5b9a\u3092\u30b9\u30ad\u30c3\u30d7\u3057\u3066\u3057\u307e\u3046\u3088\u3046\u3067\u3059\u3002\u89e3\u6c7a\u65b9\u6cd5\u3068\u3057\u3066\u306f<br \/>\n[Java]<br \/>\n@Override<br \/>\npublic void onLoadResource (WebView view, String url)<br \/>\n{<br \/>\n}<br \/>\n[\/Java]<br \/>\n\u306f\u53cd\u5fdc\u3059\u308b\u306e\u3067\u3001AJax\u306a\u3069\u3068\u51e6\u7406\u3092\u5171\u901a\u306b\u3057\u3066\u3082\u554f\u984c\u306a\u304f\u3001onLoadResource()\u306b\u7f6e\u304d\u63db\u3048\u53ef\u80fd\u306a\u5834\u5408\u306f\u3053\u3061\u3089\u3092\u4f7f\u3046\u3068\u3088\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>StackOverflow\u3067\u3082&#8221;shouldOverrideUrlLoading(\u2026) not executed if \u201cwindow.location.href\u201d modified in a timeout &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/webview-shouldoverrideurlloading-problem.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">WebView\u3067shouldOverrideUrlLoading()\u304c\u53cd\u5fdc\u3057\u306a\u3044\u554f\u984c<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85],"tags":[65],"class_list":["post-1006","post","type-post","status-publish","format-standard","hentry","category-android-dev","tag-android"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/1006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/comments?post=1006"}],"version-history":[{"count":0,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/1006\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=1006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=1006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=1006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}