{"id":54,"date":"2013-03-28T14:16:45","date_gmt":"2013-03-28T05:16:45","guid":{"rendered":"https:\/\/www.united-bears.co.jp\/blog\/?p=54"},"modified":"2013-03-28T14:16:45","modified_gmt":"2013-03-28T05:16:45","slug":"%e3%83%87%e3%83%90%e3%83%83%e3%82%b0%e3%81%99%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%afalert%e4%bd%bf%e3%81%86%e3%81%93%e3%81%a8%e3%82%82%e3%81%82%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.united-bears.co.jp\/blog\/archives\/54","title":{"rendered":"\u30c7\u30d0\u30c3\u30b0\u3059\u308b\u3068\u304d\u306falert()\u4f7f\u3046\u3053\u3068\u3082\u3042\u308b"},"content":{"rendered":"<p>JavaScript \u306e\u30c7\u30d0\u30c3\u30b0\u3092\u884c\u3046\u3068\u304d\u306f\u3001console.log()\u3092\u4f7f\u3046\u3051\u3069\u3001Android \u306e WebView \u3067 \u306e\u4f7f\u3044\u65b9\u3092\u8abf\u3079\u308b\u306e\u304c\u9762\u5012\u3060\u3063\u305f\u306e\u3067\u3001\u3053\u3093\u306a\u3068\u304d\u306f alert() \u3067\u3057\u3087\u3068\u601d\u3063\u305f\u3089\u30fb\u30fb\u30fb\u4f7f\u3048\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>WebView \u3092\u7d99\u627f\u3057\u305f\u30af\u30e9\u30b9\u3067\u3001assets \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u7f6e\u3044\u305f HTML \u3092\u8aad\u307f\u8fbc\u3080\u3002<\/p>\n<pre>public MonthlyView(Context context) {\r\n    super(context);\r\n    \/** \u7701\u7565 **\/\r\n    WebSettings settings = getSettings();\r\n    settings.setJavaScriptEnabled(true);\r\n    \/** \u7701\u7565 **\/\r\n    loadUrl(context.getString(\"file:\/\/\/android_asset\/view\/monthly.html\"));\r\n}<\/pre>\n<p>HTML \u306e\u4e2d\u3067\u3001\u3075\u3064\u3046\u306b alert() \u3092\u547c\u3073\u51fa\u3059\u3002<\/p>\n<pre>&lt;!DOCTYPE HTML&gt;\r\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"&gt;\r\n\/** \u7701\u7565 **\/\r\n&lt;body onload=\"alert('Hello World!');\"&gt;<\/pre>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8d77\u52d5\u3057\u3066\u3001\u753b\u9762\u3092\u8868\u793a\u3059\u308c\u3070\u30a2\u30e9\u30fc\u30c8\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u308b\u306f\u305a\u306a\u3093\u3060\u3051\u3069\u51fa\u306a\u3044\u3002\u8abf\u3079\u3066\u307f\u308b\u3068\u3001setWebChromeClient()\u3057\u306a\u3044\u3068\u3060\u3081\u306a\u3088\u3046\u3060\u3002<a href=\"http:\/\/developer.android.com\/reference\/android\/webkit\/WebView.html\" target=\"_blank\">WebView \u306e\u30af\u30e9\u30b9\u306e\u8aac\u660e<\/a>\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a18\u8ff0\u304c\u3042\u3063\u305f\u3002<\/p>\n<blockquote><p>Creating and setting a WebChromeClient subclass. This class is called when something that might impact a browser UI happens, for instance, progress updates and JavaScript alerts are sent here (see Debugging Tasks).<\/p><\/blockquote>\n<p>\u30b3\u30fc\u30c9\u306b\u4ee5\u4e0b\u306e\u4e00\u884c\u3092\u52a0\u3048\u308c\u3070\u3088\u3044\u3060\u3051\u306a\u306e\u3060\u3051\u3069\u3001alert() \u3092\u547c\u3073\u51fa\u3059\u305f\u3081\u3060\u3051\u306b\u8a2d\u5b9a\u3059\u308b\u306e\u3082\u304a\u304b\u3057\u306a\u8a71\u3060\u3002<\/p>\n<pre>\r\nsetWebChromeClient(new WebChromeClient());\r\n<\/pre>\n<p>\u6700\u521d\u306b\u623b\u3063\u3066\u3001console.log \u3092\u8abf\u3079\u3066\u307f\u308b\u3002\u30fb\u30fb\u30fb\u3084\u3063\u3071\u308a\u3053\u3063\u3061\u304c\u666e\u901a\u306e\u4f7f\u3044\u65b9\u3067\u3057\u305f\u3002console.log() \u3092\u547c\u3073\u51fa\u3059\u3068\u3001logcat \u306b\u300cWeb Console\u300d\u3068\u3044\u3046\u30bf\u30b0\u3067\u666e\u901a\u306b\u51fa\u529b\u3055\u308c\u305f\u306e\u3067\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript \u306e\u30c7\u30d0\u30c3\u30b0\u3092\u884c\u3046\u3068\u304d\u306f\u3001console.log()\u3092\u4f7f\u3046\u3051\u3069\u3001Android \u306e WebView \u3067 \u306e\u4f7f\u3044\u65b9\u3092\u8abf\u3079\u308b\u306e\u304c\u9762\u5012\u3060\u3063\u305f\u306e\u3067\u3001\u3053\u3093\u306a\u3068\u304d\u306f alert() \u3067\u3057\u3087\u3068\u601d\u3063\u305f\u3089\u30fb\u30fb\u30fb\u4f7f\u3048\u307e\u305b [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[],"class_list":["post-54","post","type-post","status-publish","format-standard","hentry","category-android","category-android-develop"],"_links":{"self":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":3,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions\/63"}],"wp:attachment":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}