您好,欢迎访问一九零五行业门户网

网页创建快捷方式到桌面多种方法_PHP教程

我们会看到很多的网站不但有设置首页,加入收藏同时还有一个加和到桌面快捷方式的功能,下面我来给大家介绍网页创建快捷方式到桌面多种方法介绍。有需要的朋友可参考。
最简单的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(请点击弹出对话框的:是 ); 

}
不足:这样做如果浏览器做了安全设置我们是不能使用上面的方法的。
写php程序的朋友可能也知道一种办法,代码如下
 代码如下 复制代码
发送到桌面
asp.net程序员可能也知道如下代码
代码如下 复制代码
using system;
using system.data;
using system.configuration;
using system.collections;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;
public partial class createshortcut : system.web.ui.page
{
protected void page_load(object sender, eventargs e)
{
}
///
/// 创建快捷方式
///
/// 标题
/// url地址
private void createshortcut(string title, string url)
{
string strfavoritefolder;
// “收藏夹”中 创建 ie 快捷方式
strfavoritefolder = system.environment.getfolderpath(environment.specialfolder.favorites);
createshortcutfile(title, url, strfavoritefolder);
// “ 桌面 ”中 创建 ie 快捷方式
strfavoritefolder = system.environment.getfolderpath(environment.specialfolder.desktop);
createshortcutfile(title, url, strfavoritefolder);
// “ 链接 ”中 创建 ie 快捷方式
strfavoritefolder = system.environment.getfolderpath(environment.specialfolder.favorites) + 链接;
createshortcutfile(title, url, strfavoritefolder);
//「开始」菜单中 创建 ie 快捷方式
strfavoritefolder = system.environment.getfolderpath(environment.specialfolder.startmenu);
createshortcutfile(title, url, strfavoritefolder);
}
///
/// 创建快捷方式
///
/// 标题
/// url地址
/// 特殊文件夹
private void createshortcutfile(string title, string url, string specialfolder)
{
// create shortcut file, based on title
system.io.streamwriter objwriter = system.io.file.createtext(specialfolder + + title + .url);
// write url to file
objwriter.writeline([internetshortcut]);
objwriter.writeline(url= + url);
// close file
objwriter.close();
}
private void btnshortcut_click(object sender, system.eventargs e)
{
createshortcut(脚本之家, http://www.bkjia.com);
}
}
http://www.bkjia.com/phpjc/444613.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/444613.htmltecharticle我们会看到很多的网站不但有设置首页,加入收藏同时还有一个加和到桌面快捷方式的功能,下面我来给大家介绍网页创建快捷方式到桌面...
其它类似信息

推荐信息