Skip to content

Instantly share code, notes, and snippets.

@azl397985856
Last active September 22, 2020 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azl397985856/3a217d034c7fa59c7993542c0ca543d8 to your computer and use it in GitHub Desktop.
Save azl397985856/3a217d034c7fa59c7993542c0ca543d8 to your computer and use it in GitHub Desktop.

检查弹出是否被屏蔽(比如插件屏蔽)

let blocked = false;

try {
  let wroxWin = window.open("http://www.wrox.com", "_blank");
  if (wroxWin == null){
    blocked = true;
  }
} catch (ex){
  blocked = true;
}
if (blocked){
  alert("The popup was blocked!");
}

强制刷新,不取缓存

location.reload();     // 重新加载,可能是从缓存加载
location.reload(true); // 重新加载,从服务器加载

注册处理程序

邮件

navigator.registerProtocolHandler("mailto",
  "http://www.somemailclient.com?cmd=%s",
  "Some Mail Client");

钉钉

需求要实现浏览器页面的分享功能,需点击分享打开钉钉PC端的功能。

查看官方文档,只提供了打开对应某个人的协议方式: <a href="dingtalk://dingtalkclient/action/sendmsg?dingtalk_id={id}"></a> ,同时需要制定钉钉号。

如果只是单纯唤起客户端,则可以考虑如下协议,尝试有效:

dingtalk://dingtalkclient/page/link

或者

dingtalk://dingtalkclient/action/switchtab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment