PHP网站头部通栏设计

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

 

 

 

 

转载于:https://www.cnblogs.com/ItcastZc/p/4086737.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值