判断手机是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对象的拷贝

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值