WEB前端|这里分别用asp,PHP,js把网址保存到桌面,设为桌面快捷方式,方便用户直接登录网站PHP代码教程1、将下面的代码保存为文件,url.php。记得修改第二行及第四行内的url名称和网址。
这里分别用asp,PHP,js把网址保存到桌面,设为桌面快捷方式,方便用户直接登录网站
PHP代码教程
1、将下面的代码保存为文件,url.php。记得修改第二行及第四行内的url名称和网址。
<?php
$Shortcut = "[InternetShortcut]
URL=https://putishu.wang
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
";
Header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=名称.url;");
echo $Shortcut;
?>2、将该文件上传至网站根目录。
3、在网站根目录上传Favicon.ico文件,有这个文件,保存的链接才会有图标显示。
4、在网站调用页面添加如下代码即可。
<a href='https://putishu.wang/url.php'>桌面图标</a>
附Asp代码 及Js代码
<%
Response.ContentType="APPLICATION/OCTET-STREAM"
Response.AddHeader "Content-Disposition","attachment;filename="&"名称.url" Response.Write("[InternetShortcut]")&Chr(13)
Response.Write("URL=https://putishu.wang")&Chr(13) Response.Write("IDList=")&Chr(13)
Response.Write("[{000214A0-0000-0000-C000-000000000046}]")&Chr(13)
Response.Write("Prop3=19,2")&Chr(13)
Response.End
%>js方法1
<script language="java script">
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('https://www.010080.com',' ')"js方法2 仿开心网
public function shortcutAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender( true );
$url = site_url();
$Shortcut = "
[InternetShortcut]
URL=".$url."
IDList=IconIndex=43
IconFile=/favicon.ico
HotKey=1626
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2";
Header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=名称.url");
echo $Shortcut;
}
4