根据用户设备进行页面分发,移动端 or PC端
新建三个页面
分别为
index.html
pc.html
phone.html
在index.html的script中写入以下代码作为判断是pc还是移动端进行页面的分发
<!-- 用来判断用户的设备具体是什么,从而分发到对应得到页面中 -->
<script>
// test()方法用于检测一个字符串中是否匹配某个模式 true false
window.location.href=/Android|webOs|iPhone|iPod|BlackBerry/i.test(navigator.useerAgent)?"phone.html":"pc.html"
</script>