1.把网站添加到桌面:
<a href="shortcut.php">放到桌面上</a> <?PHP $Shortcut = "[InternetShortcut] URL=http://www.xxx.com IDList= IconFile=http://www.xxx.com/favicon.ico//图标 IconIndex=1 [{000214A0-0000-0000-C000-000000000046}] Prop3=19,2"; Header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=xxx.url"); echo $Shortcut; ?>
2.设为首页:
目前这种方法只支持IE内核的浏览器
<a target="_self" href="http://www.xxx.com/" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.xxx.com/');">设为首页</a>
3.加入收藏:
<a href="javascript:addFavorite();">加入收藏</a> <script text="text/javascript"> function addFavorite() { var url = window.location.href; var title = document.title; try { window.external.addFavorite(url, title); } catch (e) { try { window.sidebar.addPanel(title, url, ""); } catch (e) { alert("抱歉,您所使用的浏览器无法完成此操作,请使用Ctrl+D进行添加"); } } } </script>
4.下载文档:
以DOC为例
<?php $filename = "xxxxxx.docx"; header("Cache-Control: public"); header("Content-Description: File Transfer"); header('Content-disposition:attachment; filename='.basename($filename)); header("Content-Type: application/msword"); //docx或doc格式 header("Content-Transfer-Encoding: binary"); header('Content-Length: '. filesize($filename)); readfile($filename); ?>
这里附加一些常用的Content-Type:
'exe' -> 'application/octet-stream'
'pdf' -> 'application/pdf',
'dll' -> 'application/octet-stream',
'pdf' -> 'application/pdf',
'ai' -> 'application/postscript',
'xls'->'application/vnd.ms-excel', 'ppt' -> 'application/vnd.ms-powerpoint',
'xml' -> 'text/xml',
'txt' -> 'text/plain',
'jpg' -> 'image/jpeg',
'png' -> 'image/png',
'zip' -> 'application/zip',
'tar' -> 'application/x-tar',
'swf' -> 'application/x-shockwave-flash',