保存链接到桌面、设为桌面快捷方式的php、asp代码_众多像我一样的个人站长们的问题
[js方法]
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安全级别不允许操作!请设置后在操作.”);
}}
type=“button“
id=“btn“
value=“创建的快捷方式“
onClick=“toDesktop(‘http:\//www.boshi8.com/’,'博士吧’)“>
[仿开心网的设为桌面]
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;
}
[ASP方法]
就会有提示下载一个名为 宅急信-青城最及时的房屋信息网.url 文件,保存在本地就是一个快捷方式!
1、将下面的代码保存为文件,shorturl.asp。记得修改第二行及第四行内的url名称和网址。
Response.ContentType=”APPLICATION/OCTET-STREAM”
Response.AddHeader
“Content-Disposition”,”attachment;filename=”&”博士吧设计.url”
Response.Write(“[InternetShortcut]“)&Chr(13)
Response.Write(“URL=http://www.cnarrow.com”)&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
%>
2、将该文件上传至网站根目录。
3、在网站根目录上传Favicon.ico文件,有这个文件,保存的链接才会有图标显示。
4、在网站调用页面添加如下代码即可。
href=’http://www.boshi8.com/shorturl.asp’>桌面图标
[PHP方法]
另附PHP代码,大家可以尝试一下,保存成shorturl.php即可,调用方式同asp。
$Shortcut = “[InternetShortcut]
URL=http://www.cnarrow.com/
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
“;
Header(“Content-type: application/octet-stream”);
header(“Content-Disposition: attachment; filename=宏箭.url;”);
echo $Shortcut;
?>
要想出现图标请先确保网站根目录中有 favicon.ico
文件上传到网站保存链接到桌面、设为桌面快捷方式的js、php、asp代码_