码迷,mamicode.com
首页 > Web开发 > 详细

PHP网站头部通栏设计

时间:2014-11-10 13:29:44      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   color   ar   os   使用   

bubuko.com,布布扣

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‘,

 

 

 

 

PHP网站头部通栏设计

标签:des   style   blog   http   io   color   ar   os   使用   

原文地址:http://www.cnblogs.com/ItcastZc/p/4086737.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!