Posted in Javascript onDecember 27, 2012
function toDesktop(sUrl,sName){ try{ var WshShell = new ActiveXObject("WScript.Shell"); var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "\\" + sName + ".url"); oUrlLink.TargetPath = sUrl; oUrlLink.Save(); }catch(e){ alert("当前IE安全级别不允许操作!"); } } <a href="javascript:void(0);" onclick="toDesktop('http:\//www.163.com/','163网易')">创建快捷方式</a>
<!---把以下文本复制到记事本里面,然后保存成 .htm 格式文件,用IE打开就可以预览效果了---> <script language="JavaScript"> function toDesktop(sUrl,sName){ try { var WshShell = new ActiveXObject("WScript.Shell"); var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "\\" + sName + ".url"); oUrlLink.TargetPath = sUrl; oUrlLink.Save(); } catch(e) { alert("当前IE安全级别不允许操作!"); } } </script> <input name="btn" type="button" id="btn" value="星光下载" onClick="toDesktop('http:\//cjss.tsh88.cn/','超级搜索')"> <input name="btn" type="button" id="btn" value="C盘" onClick="toDesktop('file:\//C:','C盘')">
JS 添加网页桌面快捷方式的代码详细整理
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@