最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS控制圖片翻轉(zhuǎn)示例代碼(兼容firefox,ie,chrome)

 更新時(shí)間:2013年12月19日 09:10:37   作者:  
本篇文章主要介紹了JS控制圖片翻轉(zhuǎn)示例代碼(兼容firefox,ie,chrome) 需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助
復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>圖片旋轉(zhuǎn)效果</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--把下面代碼加到<head>與</head>之間-->
<style type="text/css">
ul{padding:0 15px;}
ul li{padding-bottom:15px;border-bottom:1px dashed #EEE;}
.caption{padding:15px 0 5px;}
.caption input{margin-right:10px;padding:0 10px;}
</style>
<script type="text/javascript">
/*
* www.byzuo.com
* ok!: MSIE 6, 7, 8, Firefox 3.6, chrome 4, Safari 4, Opera 10
* o 旋轉(zhuǎn)圖片ID;
* p 選擇旋轉(zhuǎn)方向,固定值為'left'或'right';
*/
function rotate(o,p){
    var img = document.getElementById(o);
    if(!img || !p) return false;
    var n = img.getAttribute('step');
    if(n== null) n=0;
    if(p=='right'){
        (n==3)? n=0:n++;
    }else if(p=='left'){
        (n==0)? n=3:n--;
    }
    img.setAttribute('step',n);
    //MSIE
    if(document.all) {
        img.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation='+ n +')';
        //HACK FOR MSIE 8
        switch(n){
            case 0:
                imgimg.parentNode.style.height = img.height;
                break;
            case 1:
                imgimg.parentNode.style.height = img.width;
                break;
            case 2:
                imgimg.parentNode.style.height = img.height;
                break;
            case 3:
                imgimg.parentNode.style.height = img.width;
                break;
        }
    //DOM
    }else{
        var c = document.getElementById('canvas_'+o);
        if(c== null){
            img.style.visibility = 'hidden';
            img.style.position = 'absolute';
            c = document.createElement('canvas');
            c.setAttribute("id",'canvas_'+o);
            img.parentNode.appendChild(c);
        }
        var ccanvasContext = c.getContext('2d');
        switch(n) {
            default :
            case 0 :
                c.setAttribute('width', img.width);
                c.setAttribute('height', img.height);
                canvasContext.rotate(0 * Math.PI / 180);
                canvasContext.drawImage(img, 0, 0);
                break;
            case 1 :
                c.setAttribute('width', img.height);
                c.setAttribute('height', img.width);
                canvasContext.rotate(90 * Math.PI / 180);
                canvasContext.drawImage(img, 0, -img.height);
                break;
            case 2 :
                c.setAttribute('width', img.width);
                c.setAttribute('height', img.height);
                canvasContext.rotate(180 * Math.PI / 180);
                canvasContext.drawImage(img, -img.width, -img.height);
                break;
            case 3 :
                c.setAttribute('width', img.height);
                c.setAttribute('height', img.width);
                canvasContext.rotate(270 * Math.PI / 180);
                canvasContext.drawImage(img, -img.width, 0);
                break;
        }
    }
}
</script>
</head>
<body>
<!--把下面代碼加到<body>與</body>之間-->
<ul class="clearfix">
    <li>
        <div class="caption">
            <input type="button" value="turn left" onclick="rotate('pic_1','left')">
            <input type="button" value="turn right" onclick="rotate('pic_1','right')">
        </div>
        <div class="cont">
            <img  alt="javascript 圖片旋轉(zhuǎn)效果"  id="pic_1" src="1.gif" alt="">
        </div>
    </li>
</ul>
</body>
</html>

相關(guān)文章

  • JavaScript 監(jiān)控微信瀏覽器且自帶返回按鈕時(shí)間

    JavaScript 監(jiān)控微信瀏覽器且自帶返回按鈕時(shí)間

    這篇文章主要介紹了JavaScript 監(jiān)控微信瀏覽器且自帶返回按鈕時(shí)間的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-11-11
  • Javascript中arguments用法實(shí)例分析

    Javascript中arguments用法實(shí)例分析

    這篇文章主要介紹了Javascript中arguments用法,實(shí)例分析了javascript利用arguments實(shí)現(xiàn)模擬重載功能,需要的朋友可以參考下
    2015-06-06
  • Rxjs tap 操作符的使用場(chǎng)景示例

    Rxjs tap 操作符的使用場(chǎng)景示例

    這篇文章主要為大家介紹了Rxjs tap 操作符的使用場(chǎng)景示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07
  • 微信小程序iBeacon測(cè)距及穩(wěn)定程序的實(shí)現(xiàn)解析

    微信小程序iBeacon測(cè)距及穩(wěn)定程序的實(shí)現(xiàn)解析

    這篇文章主要介紹了微信小程序iBeacon測(cè)距及穩(wěn)定程序的實(shí)現(xiàn)解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-07-07
  • 一文詳解requestAnimationFrame請(qǐng)求動(dòng)畫(huà)幀

    一文詳解requestAnimationFrame請(qǐng)求動(dòng)畫(huà)幀

    requestAnimationFrame是一個(gè)用于動(dòng)畫(huà)效果的 API,它使用瀏覽器的刷新率來(lái)執(zhí)行回調(diào)函數(shù),通常每秒鐘執(zhí)行60次,這篇文章主要給大家介紹了關(guān)于requestAnimationFrame請(qǐng)求動(dòng)畫(huà)幀的相關(guān)資料,需要的朋友可以參考下
    2023-12-12
  • 正則中的回溯定義與用法分析【JS與java實(shí)現(xiàn)】

    正則中的回溯定義與用法分析【JS與java實(shí)現(xiàn)】

    這篇文章主要介紹了正則中的回溯定義與用法,結(jié)合實(shí)例形式分析了回溯的概念、功能并提供了JS與java實(shí)現(xiàn)方法,需要的朋友可以參考下
    2016-12-12
  • JavaScript之Getters和Setters 平臺(tái)支持等詳細(xì)介紹

    JavaScript之Getters和Setters 平臺(tái)支持等詳細(xì)介紹

    現(xiàn)在,JavaScript的Getters和Setters使用非常廣泛,它和每個(gè)JavaScript開(kāi)發(fā)者的切身利益息息相關(guān),我們先來(lái)快速了解什么是Getters和Setters,以及它們?yōu)槭裁春苡杏?然后,我們來(lái)看看現(xiàn)在都有哪些平臺(tái)支持Gettets和Setters
    2012-12-12
  • 微信小程序?qū)崿F(xiàn)滑動(dòng)驗(yàn)證拼圖

    微信小程序?qū)崿F(xiàn)滑動(dòng)驗(yàn)證拼圖

    這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)滑動(dòng)驗(yàn)證拼圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • js判斷FCKeditor內(nèi)容是否為空的兩種形式

    js判斷FCKeditor內(nèi)容是否為空的兩種形式

    FCKeditor內(nèi)容是否為空在提交表單時(shí)一定要判斷的,下面與大家分享下兩種形式,感興趣的朋友可以參考下哈
    2013-05-05
  • 微信小程序如何訪問(wèn)公眾號(hào)文章

    微信小程序如何訪問(wèn)公眾號(hào)文章

    這篇文章主要介紹了微信小程序如何訪問(wèn)公眾號(hào)文章,隨著小程序不斷的發(fā)展,現(xiàn)在個(gè)人的小程序也開(kāi)放了很多功能了,個(gè)人小程序直接打開(kāi)公眾號(hào)鏈接。在群里看到的一款小程序,點(diǎn)擊可以直接閱讀文章了,需要的朋友可以參考下
    2019-07-07

最新評(píng)論

泸州市| 达日县| 枞阳县| 嘉祥县| 庐江县| 崇明县| 卢湾区| 当涂县| 高邮市| 武鸣县| 密山市| 婺源县| 锡林郭勒盟| 康乐县| 榕江县| 会泽县| 五台县| 宁河县| 周口市| 盐城市| 崇明县| 惠州市| 临沧市| 凤冈县| 临城县| 三门县| 福清市| 永寿县| 丹东市| 沙田区| 龙胜| 沧州市| 平凉市| 鄂托克前旗| 奇台县| 郧西县| 郁南县| 永仁县| 洛隆县| 株洲县| 肇东市|