设为首页收藏本站关注微信<<< 抵制 IE6 人人有责 >>>
搜索
热搜: 活动 交友 discuz
查看: 2002|回复: 0
打印 上一主题 下一主题

[Html] php及js、asp实现将网址保存到桌面,设为桌面图标的代码

[复制链接]
跳转到指定楼层
楼主
发表于 2015-5-15 01:24:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
PHP代码教程
1、将下面的代码保存为文件,url.php。记得修改第二行及第四行内的url名称和网址。
  1. <?php
  2. $Shortcut = "[InternetShortcut]
  3. URL=http://www.kevin-ying.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=kevin-ying.url;");
  10. echo $Shortcut;
  11. ?>
复制代码



2、将该文件上传至网站根目录。
3、在网站根目录上传Favicon.ico文件,有这个文件,保存的链接才会有图标显示。
4、在网站调用页面添加如下代码即可。
<a href='http://www.kevin-ying.com/url.php'>桌面图标</a>
附Asp代码 及Js代码
  1. <%
  2. Response.ContentType="APPLICATION/OCTET-STREAM"
  3. Response.AddHeader "Content-Disposition","attachment;filename="&"kevin-ying.url"
  4. Response.Write("[InternetShortcut]")&Chr(13)
  5. Response.Write("URL=http://www.kevin-ying.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. %>
复制代码


js方法1
  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://www.kevin-ying.com/','kevin-ying')"
复制代码




js方法2
  1. view sourceprint?
  2. public function shortcutAction()
  3. {
  4. $this->_helper->layout->disableLayout();
  5. $this->_helper->viewRenderer->setNoRender( true );
  6. $url = site_url();
  7. $Shortcut = "
  8. [InternetShortcut]
  9. URL=".$url."
  10. IDList=IconIndex=43
  11. IconFile=/favicon.ico
  12. HotKey=1626
  13. [{000214A0-0000-0000-C000-000000000046}]
  14. Prop3=19,2";
  15. Header("Content-type: application/octet-stream");
  16. header("Content-Disposition: attachment; filename=kevin-ying.url");
  17. echo $Shortcut;
  18. }
复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享淘帖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

QQ|手机版|Archiver|源于生活(个人生活娱乐工作的笔记)css3,html5,学习笔记    

GMT+8, 2024-4-27 07:52 , Processed in 0.078000 second(s), 27 queries .

Powered by Mr.Kevin-ying

© 2004-2015

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