六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 1375|回复: 0

保存到桌面、设为桌面的代码【js、php、asp】-it论坛

[复制链接]
 楼主| 发表于 2013-12-30 11:16:52 | 显示全部楼层 |阅读模式
保存到桌面、设为桌面的代码【js、php、asp】-it论坛-计算机论坛
js方法
  1. <script language="JavaScript">
  2. function toDesktop(sUrl,sName)
  3. {
  4. try
  5. {
  6. var WshShell = new ActiveXObject("WScript.Shell");
  7. var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "//" + sName + ".url");
  8. oUrlLink.TargetPath = sUrl;
  9. oUrlLink.Save();
  10. }
  11. catch(e)
  12. {
  13. alert("当前IE安全级别不允许操作!请设置后在操作.");
  14. }
  15. }
  16. </script>
  17. <input name="btn" type="button" id="btn" value="创建的快捷方式" onClick="toDesktop('http://mall.agoit.com/','IT商城'">创建的快捷方式</a>
复制代码
仿开心网的设为桌面

  1. public function shortcutAction()
  2. {
  3. $this->_helper->layout->disableLayout();
  4. $this->_helper->viewRenderer->setNoRender( true );
  5. $url = site_url();
  6. $Shortcut = "
  7. [InternetShortcut]
  8. URL=".$url."
  9. IDList=IconIndex=43
  10. IconFile=/favicon.ico
  11. HotKey=1626
  12. [{000214A0-0000-0000-C000-000000000046}]
  13. Prop3=19,2";
  14. Header("Content-type: application/octet-stream");
  15. header("Content-Disposition: attachment; filename=开心网.url");
  16. echo $Shortcut;
  17. }
复制代码
1、将下面的代码保存为文件,shorturl.asp。记得修改第二行及第四行内的url名称和网址。
  1. <%
  2. Response.ContentType="APPLICATION/OCTET-STREAM"
  3. Response.AddHeader "Content-Disposition","attachment;filename="&"IT商城.url"
  4. Response.Write("[InternetShortcut]")&Chr(13)
  5. Response.Write("URL=http://mall.agoit.com")&Chr(13)
  6. Response.Write("IDList=")&Chr(13)
  7. Response.Write("[{000214A0-0000-0000-C000-000000000046}]")&Chr(13)
  8. Response.Write("Prop3=19,2")&Chr(13)
  9. Response.End
  10. %>
复制代码
2、将该文件上传至网站根目录。
3、在网站根目录上传Favicon.ico文件,有这个文件,保存的链接才会有图标显示。
4、在网站调用页面添加如下代码即可。
  1. <a href='http://mall.agoit.com/shorturl.asp'>桌面图标</a>
复制代码
另附PHP代码,大家可以尝试一下,保存成shorturl.php即可,调用方式同asp。
  1. <?php
  2. $Shortcut = "[InternetShortcut]
  3. URL=http://mall.agoit.com/
  4. IDList=
  5. [{000214A0-0000-0000-C000-000000000046}]
  6. Prop3=19,2
  7. ";
  8. Header("Content-type: application/octet-stream");
  9. header("Content-Disposition: attachment; filename=IT商城.url;");
  10. echo $Shortcut;
  11. ?>
复制代码
本文摘自:http://blog.csdn.net/coklo/article/details/6269289


该会员没有填写今日想说内容.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表