1、创建一个打开ie浏览器的脚本 alert.bat

其中,C:\\Program Files\\Internet Explorer\\iexplore.exe 为ie安装的位置

使用 separator 替换 & 可以带多个参数

@echo off
set m=%m:alert:=%
set m="%m:separator=&%"
start "" "C:\\Program Files\\Internet Explorer\\iexplore.exe" %m%
exit

2、创建注册协议的注册表 alert.reg

其中,D:\\workspace\\test\\chormeToIE\\alert.bat 为第一步文件的位置

Windows Registry Editor Version 5.00
 
[HKEY_CLASSES_ROOT\alert]
@="URL:Alert Protocol"
"URL Protocol"=""
 
[HKEY_CLASSES_ROOT\alert\DefaultIcon]
@="iexplore.exe,1"
 
[HKEY_CLASSES_ROOT\alert\shell]
 
[HKEY_CLASSES_ROOT\alert\shell\open\command]
@="cmd /c set m=%1 & \"D:\\workspace\\test\\chormeToIE\\alert.bat\" %%m%% & exit"

3、创建注册脚本 runreg.bat,并且双击运行

REGEDIT /S alert.reg

4、测试

关键代码:

window.location.href = "alert:" + url ;
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>
    <button onclick="test()">
      test
    </button>
    </div>
  <script>
    function test() {
      var url ='https://www.baidu.com?a=1separatorb=2';
window.location.href = "alert:" + url ;
}
</script>
</body>
</html>

 

posted on 2022-07-21 13:37  浅悠  阅读(1422)  评论(0编辑  收藏  举报