{"id":1187,"date":"2011-08-18T02:01:09","date_gmt":"2011-08-17T17:01:09","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=1187"},"modified":"2012-02-10T01:41:11","modified_gmt":"2012-02-09T16:41:11","slug":"%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3-javascript-%e3%83%a6%e3%83%bc%e3%82%b6%e3%83%bc%e3%82%a8%e3%83%bc%e3%82%b8%e3%82%a7%e3%83%b3%e3%83%88%e6%8c%af%e5%88%86%e3%81%91","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=1187","title":{"rendered":"\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3 JavaScript \u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u632f\u5206\u3051"},"content":{"rendered":"<div>\n<div>\n<p>JavaScript\u3092\u7528\u3044\u3066\u3001\u300c\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u300d\u306e\u632f\u308a\u5206\u3051\u306e\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3068\u306fweb\u30d6\u30e9\u30a6\u30b6\u30fc\u3084\u691c\u7d22\u30a8\u30f3\u30b8\u30f3\u306e\u30af\u30ed\u30fc\u30e9\u30fc\u3068\u3044\u3063\u305fweb\u30b5\u30a4\u30c8\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u3053\u3068\u3092\u3044\u3046\u306e\u3067\u3059\u304c\u3001web\u5236\u4f5c\u3067\u306f\u4e00\u822c\u7684\u306b\u300cweb\u30d6\u30e9\u30a6\u30b6\u30fc\u304cHTTP\u901a\u4fe1\u6642\u306b\u30b5\u30fc\u30d0\u30fc\u3078\u9001\u4fe1\u3059\u308b\u56fa\u6709\u306e\u6587\u5b57\u5217\u60c5\u5831\u300d\u306e\u3053\u3068\u3092\u6307\u3057\u307e\u3059\u3002<\/p>\n<h4>iPhone \u3001iPad\u306e\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8<\/h4>\n<h5>iPhone4 :iOS4<\/h5>\n<p>Mozilla\/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit\/532.9 (KHTML, like Gecko) Version\/4.0.5 Mobile\/8A293 Safari\/6531.22.7<\/p>\n<h5>iPhone3G\/3GS : iOS4<\/h5>\n<p>Mozilla\/5.0 (iPhone Simulator; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit\/532.9 (KHTML, like Gecko) Version\/4.0.5 Mobile\/8A293 Safari\/6531.22.7<\/p>\n<h5>iPad :iPhoneOS3.2<\/h5>\n<p>Mozilla\/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit\/531.21.10 (KHTML, like Gecko) Version\/4.0.4 Mobile\/7W367a Safari\/531.21.10<\/p>\n<h5>iPhone3G : iPhoneOS3.1.3<\/h5>\n<p>Mozilla\/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; ja-jp) AppleWebKit\/528.18 (KHTML, like Gecko) Version\/4.0 Mobile\/7E18 Safari\/528.16<\/p>\n<p>\u3053\u308c\u3089\u306e\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3057\u3001javascript\u3092\u7528\u3044\u3066\u632f\u308a\u5206\u3051\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p><strong>JavaScript\u3067\u306f<\/strong><\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">navigator.userAgent<\/pre>\n<\/p>\n<p>\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u53d6\u5f97\u3057\u305f\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u6587\u5b57\u5217\u306b\u300ciPhone\u300d\u300cAndroid\u300d\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\uff1f\u3092indexOf()\u30e1\u30bd\u30c3\u30c9\u3067\u5224\u65ad\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001<strong>iPhone\u304b\u3069\u3046\u304b<\/strong><\/p>\n<h4>1.\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u53d6\u5f97 iPhone<\/h4>\n<p>\u4f8b\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nif(navigator.userAgent.indexOf('iPhone') &gt; 0){\r\nalert(&quot;\u3042\u306a\u305f\u306e\u30c7\u30d0\u30a4\u30b9\u306fiPhone\u3067\u3059\u3002&quot;);\r\n}else{\r\nalert(&quot;\u3042\u306a\u305f\u306e\u30c7\u30d0\u30a4\u30b9\u306fiPhone\u3067\u306f\u306a\u3044\u3067\u3059\u3002&quot;);\r\n}<\/pre>\n<\/p>\n<p>indexOf()\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u767a\u898b\u3059\u308b\u3068\u6587\u5b57\u5217\u4e2d\u306e\u4f4d\u7f6e\u3092\u3001<\/p>\n<p>\u767a\u898b\u3067\u304d\u306a\u3044\u3068\u300c-1\u300d\u306e\u6570\u5024\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092\u5229\u7528\u3057\u3001\u5024\u304c\uff10\u3088\u308a\u4e0a\u3067\u3042\u308c\u3070\u30ad\u30fc\u30ef\u30fc\u30c9\u767a\u898b\uff08iPhone\u3067\u306e\u30a2\u30af\u30bb\u30b9\uff09<\/p>\n<p>\u3068\u5224\u65ad\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>iPhone\u3060\u30680\u4ee5\u4e0a\u3001\u4ed6\u30c7\u30d0\u30a4\u30b9\u3060\u3068-1\u306e\u5024<\/p>\n<h4>\uff12.\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u53d6\u5f97 iPhone or Android<\/h4>\n<p><a href=\"http:\/\/webcyou.com\/demo\/spn\/device.html\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8<\/a><\/p>\n<p>\u7d9a\u3044\u3066\u3001<strong>Android\u304b\u3069\u3046\u304b<\/strong>\u3082\u00a0<strong>navigator.userAgent.indexOf(&#8216;Android&#8217;)<\/strong>\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">if(navigator.userAgent.indexOf('iPhone') &gt; 0){\r\nalert(&quot;\u3042\u306a\u305f\u306e\u30c7\u30d0\u30a4\u30b9\u306fiPhone\u3067\u3059\u3002&quot;);\r\n}if(navigator.userAgent.indexOf('Android') &gt; 0){\r\nalert(&quot;\u3042\u306a\u305f\u306e\u30c7\u30d0\u30a4\u30b9\u306fAndroid\u3067\u3059\u3002&quot;);\r\n}if(navigator.userAgent.indexOf('iPhone') == -1 &amp;&amp; device.indexOf('Android') == -1){\r\nalert(&quot;\u3042\u306a\u305f\u306e\u30c7\u30d0\u30a4\u30b9\u306fiPhone\u3067\u3082Android\u3067\u3082\u306a\u3044\u3067\u3059\u3002&quot;);\r\n}<\/pre>\n<\/p>\n<p>iPhone\u306e\u5834\u5408\u306f indexOf(&#8216;iPhone&#8217;)\u306e\u5024\u306f0\u4ee5\u4e0a\u3001<\/p>\n<p>Android\u306e\u5834\u5408\u306findexOf(&#8216;Android&#8217;)\u306e\u5024\u306f0\u4ee5\u4e0a\u3001<\/p>\n<p>\u3069\u3061\u3089\u3067\u3082\u306a\u3044\u5834\u5408\u306findexOf(&#8216;iPhone&#8217;)\u3001indexOf(&#8216;Android&#8217;)\u306e\u5024\u306f\u3068\u3082\u306b-1\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/webcyou.com\/demo\/spn\/device.html\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8<\/a><\/p>\n<p>\u6700\u5f8c\u306biPod touch\u3082\u542b\u3081\u3001iPad\u3092\u542b\u3081\u306a\u3044\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>iPad\u306f\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u30b5\u30a4\u30ba\u304c\u5927\u5e45\u306b\u7570\u306a\u308b\u305f\u3081\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u540c\u69d8\u306e\u8868\u793a\u3060\u3068\u9006\u306b\u898b\u3065\u3089\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u3053\u3068\u304c\u3042\u308b\u305f\u3081PC\u540c\u69d8\u306e\u6271\u3044\u3067\u632f\u308a\u5206\u3051\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>iPod touch\u306fiPhone,Android\u7aef\u672b\u3068\u540c\u3058\u69d8\u306a\u8868\u793a\u304c\u5b9f\u73fe\u3067\u304d\u308b\u305f\u3081\u3001\u540c\u3058\u300c\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u300d\u3068\u3044\u3046\u62ec\u308a\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>iPod touch\u306e\u30a2\u30af\u30bb\u30b9\u3067\u306f\u300ciPod\u300d\u3068\u3044\u3046\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u542b\u307e\u308c\u308b\u306e\u304c\u7279\u5fb4\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001iPad\u306e\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u6587\u5b57\u5217\u306b\u306f\u30ad\u30fc\u30ef\u30fc\u30c9\u300ciPad\u300d\u3057\u304b\u306a\u3044\u306e\u3067\u554f\u984c\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u521d\u671f\u306eiPad\u306e\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u6587\u5b57\u5217\u3067\u306f\u300ciPhone OS\u300d\u3068\u3044\u3046\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u30ad\u30fc\u30ef\u30fc\u30c9iPhone\u3068\u3044\u3046\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3057\u3001iPhone\u3060\u3068\u8aa4\u8a8d\u8b58\u3059\u308b\u306e\u3092\u907f\u3051\u308b\u3088\u3046\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">var device = navigator.userAgent;\r\nif((device.indexOf('iPhone') &gt; 0 &amp;&amp; device.indexOf('iPad') == -1) ......\r\n<\/pre>\n<\/p>\n<p>\u77ed\u7e2e\u3059\u308b\u305f\u3081 var device = navigator.userAgent;\u3067\u5909\u6570device\u306b\u4ee3\u5165\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>iPhone\u306e\u5024\u304c0\u4ee5\u4e0a\u304b\u3064iPad\u306e\u5024\u304c-1 \u306e\u6642\u300ciPhone\u300d<\/p>\n<h4>3.\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u53d6\u5f97 \u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3<\/h4>\n<p>\u4f8b\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvar device = navigator.userAgent;\r\nif((device.indexOf('iPhone') &gt; 0 &amp;&amp; device.indexOf('iPad') == -1) || device.indexOf('iPod') &gt; 0 || device.indexOf('Android') &gt; 0){\r\nalert(&quot;\u3042\u306a\u305f\u306e\u30c7\u30d0\u30a4\u30b9\u306f\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\uff08iPod touch\u3092\u542b\u3080\uff09\u3067\u3059\u3002&quot;);\r\n}else{\r\nalert(&quot;\u3042\u306a\u305f\u306e\u30c7\u30d0\u30a4\u30b9\u306f\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\uff08iPod touch\u3092\u542b\u3080\uff09\u3067\u306f\u306a\u3044\u3067\u3059\u3002&quot;);\r\n}\r\n<\/pre>\n<p>\u3055\u3089\u306biPod\u306e\u5024\u304c0\u4ee5\u4e0a\u306e\u6642\u3001Android\u306e\u5024\u304c0\u4ee5\u4e0a\u306e\u6642\u3044\u305a\u308c\u304b\u306e\u6761\u4ef6\u306e\u6642\u300c\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u300d\u3068\u5224\u5225\u3057\u307e\u3059\u3002<\/p>\n<p>jQuery\u3082\u542b\u3081\u305f\u30c7\u30e2\u306f\u3053\u3061\u3089\u304b\u3089\u3002<\/p>\n<p><a href=\"http:\/\/webcyou.com\/demo\/spn\/device.html\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8<\/a><\/p>\n<p><a href=\"http:\/\/webcyou.com\/demo\/spn\/device.html\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/edb0d8a48147d83e6740ead63636965f.png\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2011-08-18 1.57.03\" width=\"567\" height=\"544\" \/><\/a><\/p>\n<p>\u4ee5\u4e0a\u306b\u306a\u308a\u307e\u30fc\u3059\u3002<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript\u3092\u7528\u3044\u3066\u3001\u300c\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u300d\u306e\u632f\u308a\u5206\u3051\u306e\u65b9\u6cd5\u3067\u3059\u3002 \u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3068\u306fweb\u30d6\u30e9\u30a6\u30b6\u30fc\u3084\u691c\u7d22\u30a8\u30f3\u30b8\u30f3\u306e\u30af\u30ed\u30fc\u30e9\u30fc\u3068\u3044\u3063\u305fweb\u30b5\u30a4\u30c8\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u3053\u3068\u3092\u3044\u3046\u306e\u3067\u3059\u304c\u3001web\u5236\u4f5c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[171,59,167,177,47,179,50,116],"class_list":["post-1187","post","type-post","status-publish","format-standard","hentry","category-android","tag-android","tag-android-sdk","tag-css","tag-css3","tag-javascript-2","tag-jquery","tag-jquery-mobile","tag-116"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/1187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1187"}],"version-history":[{"count":9,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/1187\/revisions"}],"predecessor-version":[{"id":2899,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/1187\/revisions\/2899"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}