首页 > 网站 > 建站经验 > 正文

创建网页桌面快捷方式的几种方法总结

2024-04-25 20:19:35
字体:
来源:转载
供稿:网友
这篇文章主要为大家详细介绍了创建网页桌面快捷方式的几种方法总结,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,有需要的朋友可以收藏方便以后借鉴。

创建网页桌面快捷方式的一般会使用PHP和ASP两种方法。我们首先介绍PHP创建网页桌面快捷方式。

一、PHP创建网页桌面快捷方式

我们访问网站时,如果网站的内容很有吸引,一般我们都会使用浏览器的收藏夹功能,收藏此网站。 

在浏览器收藏的网页,需要打开浏览器,再从收藏夹选定访问。

如果可以在桌面直接进入到网站,这样可以为用户访问提供便利。 

我们可以使用php创建网页的快捷入口文件,保存到用户桌面,方便用户快速访问。

代码如下:

<?php$filename = '361源码网.url';$url = 'http://www.vevb.com/';$icon = 'http://www.vevb.com/favicon.ico';createShortCut($filename, $url, $icon);/** * 创建保存为桌面代码 * @param String $filename 保存的文件名 * @param String $url      访问的连接 * @param String $icon     图标路径 */function createShortCut($filename, $url, $icon=''){    // 创建基本代码    $shortCut = "[InternetShortcut]/r/nIDList=[{000214A0-0000-0000-C000-000000000046}]/r/nProp3=19,2/r/n";    $shortCut .= "URL=".$url."/r/n";    if($icon){        $shortCut .= "IconFile=".$icon."";    }    header("content-type:application/octet-stream");    // 获取用户浏览器    $user_agent = $_SERVER['HTTP_USER_AGENT'];    $encode_filename = rawurlencode($filename);    // 不同浏览器使用不同编码输出    if(preg_match("/MSIE/", $user_agent)){        header('content-disposition:attachment; filename="'.$encode_filename.'"');    }else if(preg_match("/Firefox/", $user_agent)){        header("content-disposition:attachment; filename*=/"utf8''".$filename.'"');    }else{        header('content-disposition:attachment; filename="'.$filename.'"');    }    echo $shortCut;}?>

在桌面保存为*.url后,点击就能自动打开浏览器并访问网站内容了。 


第二种方法:asp实现代码

<% id=int(request("id")) if id="" then id="1" title=request("title") If title="" Then title="361源码网" Shortcut = "[InternetShortcut] " & vbCrLf Shortcut = Shortcut & "URL=http://www.vevb.com/"&id&".html?desktop" & vbCrLf Shortcut = Shortcut & "IDList= " & vbCrLf Shortcut = Shortcut & "[{000214A0-0000-0000-C000-000000000046}] " & vbCrLf Shortcut = Shortcut & "Prop3=19,2 " & vbCrLf Shortcut = Shortcut & " " & vbCrLf Response.AddHeader "Content-Disposition", "attachment;filename="&title&".url;" Response.ContentType = "application/octet-stream" Response.Write Shortcut %>

上面就是我们经常使用的PHP和ASP2种方法实现在桌面创建网页快捷方式的代码。有需要的童鞋收藏了。

以上就是创建网页桌面快捷方式的几种方法总结的全部内容,希望对大家的学习和解决疑问有所帮助,也希望大家多多支持武林网。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表