判断手机是IOS还是安卓

//判断是ios还是安卓
  history.pushState(null, null, "#");
  window.addEventListener("popstate", function (e) {
      if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
          window.location.href = "winsion://interactive/back";
      } else if (/(Android)/i.test(navigator.userAgent)) {
          window.location.href = "winsion://interactive/finish";
      }

  });

历史记录:

history新特性pushState、replaceState

pushState()有三个参数:state对象,标题(现在是被忽略,未作处理),URL(可选)。

history.replaceState() 用起来很像pushState(),除了replaceState()是用来修改当前的history实体而不是创建一个新的。这个方法有时会很有用,当 你需要对某些用户行为作反应而更新一个state对象或者当前history实体时,可以使用它来更新state对象或者当前history实体的url

popstate事件

当history实体被改变时,popstate事件将会发生。如果history实体是有pushState和replaceState方法产生的,popstate事件的state属性会包含一份来自history实体的state对象的拷贝

猜你喜欢

转载自blog.csdn.net/AnlanJion/article/details/82853253
今日推荐