{"id":1029,"date":"2023-03-12T09:39:42","date_gmt":"2023-03-12T01:39:42","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1029"},"modified":"2023-04-29T13:12:46","modified_gmt":"2023-04-29T05:12:46","slug":"click-and-long-press-events-for-mobile-html5-page-functionality","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/12\/click-and-long-press-events-for-mobile-html5-page-functionality\/","title":{"rendered":"\u79fb\u52a8\u7aefHTML5\u9875\u9762\u529f\u80fd\u4e4b\u70b9\u51fb\u548c\u957f\u6309\u4e8b\u4ef6"},"content":{"rendered":"<p>\u79fb\u52a8\u7aefHTML5\u9875\u9762\u5f00\u53d1\u5e38\u89c1\u7684\u9700\u6c42\uff1a\u957f\u6309\u8bc6\u522b\u56fe\u4e2d\u4e8c\u7ef4\u7801<\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-javascript\">\/\/\u70b9\u51fb\u4e8b\u4ef6\ndocument.addEventListener(&quot;click&quot;, function() {\n  document.getElementById(&quot;mask&quot;).style.display = &quot;block&quot;;\n}, false)\n\n\/\/\u8bb0\u5f55\u77ed\u6309\u53ca\u957f\u6309\u4e8b\u4ef6\ndocument.getElementById(&quot;mask&quot;).addEventListener(&#039;touchstart&#039;, function(event) {\n  timestamp = (new Date()).valueOf();\n}, false);\n\ndocument.getElementById(&quot;mask&quot;).addEventListener(&#039;touchend&#039;, function(event) {\n  let current = (new Date()).valueOf();\n  if (current - timestamp &lt; 1000) {  \/\/1000ms\u5185\u4e3a\u77ed\u6309\n    document.getElementById(&quot;mask&quot;).style.display = &#039;none&#039;\n  } else {  \/\/\u957f\u6309\n\n  }\n}, false);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u79fb\u52a8\u7aefHTML5\u9875\u9762\u5f00\u53d1\u5e38\u89c1\u7684\u9700\u6c42\uff1a\u957f\u6309\u8bc6\u522b\u56fe\u4e2d\u4e8c\u7ef4\u7801 \/\/\u70b9\u51fb\u4e8b\u4ef6 document.addEventLis [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[159],"class_list":["post-1029","post","type-post","status-publish","format-standard","hentry","category-frontend-basic","tag-h5"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1029"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1029\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}