当前位置: 首页 > 网站建设 > 正文

点击把网页保存桌面的方法

山寨吧 发表于2013年4月26日 14:43
遇到好的内容请分享给更多人

网站需要增加一个点击把本网站保存桌面的按钮,怎么做呢?其实用PHP代码很容易实现的。

用php保存一个网页至桌面上成为快捷方式

<?php

$Shortcut = "[InternetShortcut]

URL=http://bbs.sz836.com

IDList=

[{000214A0-0000-0000-C000-000000000046}]

Prop3=19,2

";

$ua = $_SERVER["HTTP_USER_AGENT"];

$filename = "酷郑州.url";

$encoded_filename = urlencode($filename);

$encoded_filename = str_replace("+", "%20", $encoded_filename);

header('Content-Type: application/octet-stream');

if(preg_match("/MSIE/", $ua)){

    header('Content-Disposition: attachment; filename="'.$encoded_filename.'"');

}else if(preg_match("/Firefox/", $ua)){

    header('Content-Disposition: attachment; filename*="utf8\'\''.$filename.'"');

}else{

    header('Content-Disposition: attachment; filename="'.$filename.'"');

}

echo $Shortcut;

?>

 

你只需替换其中的http://bbs.sz836.com 为你自己的网址链接就行了。filename改成你的网站名称

然后把这代码保存为PHP文件 放在你需要的目录就行了

全文完
本文标签: 站长PHP源码
本文标题: 点击把网页保存桌面的方法
本文链接: http://blog.sz836.com/m/?post=4600

〓 随机文章推荐