我在我的网站目录中为 iPhone(不是 iPad)用户创建了一个特殊文件夹。在我的索引标题上有以下代码:<script type="text/javascript"> if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) { document.location = "mobile/";}</script>
我希望该网站对 iPad 用户来说是常规的,除了特定页面。我希望网站中的这个特定页面对 iPad(不是 iPhone)用户有所不同。我该怎么做?...
最佳答案
如果您不想包含特定的 JavaScript 文件,请检查 IIFE 中的 window.location.pathname
。
<script type="text/javascript">
(function(){
if(window.location.pathname === 'specific-page') {
// insert CSS or change stuff
return false;
}
})();
</script>
但说真的,只需在该页面的 HTML 中添加自定义 JS 文件即可。
关于html - 如何使特定网页适应 iPad 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42434101/