前端黑科技

1 . 網(wǎng)頁(yè)夜間模式

<a href="javascript:(function(){var styleElem=null,doc=document,ie=doc.all,fontColor=50,sel='body,body *';styleElem=createCSS(sel,setStyle(fontColor),styleElem);showTip(doc);if(ie){doc.attachEvent('onkeydown',onKeyDown)}else{doc.addEventListener('keydown',onKeyDown)};function onKeyDown(evt){if(!(evt.keyCode===87||evt.keyCode===81))return;var evt=ie?window.event:evt;if(evt.keyCode===87){fontColor=(fontColor>=100)?100:fontColor+10}else if(evt.keyCode===81){fontColor=(fontColor<=10)?10:fontColor-10};styleElem=createCSS(sel,setStyle(fontColor),styleElem)};function setStyle(fontColor){var colorArr=[fontColor,fontColor,fontColor];return'background-color:rgb(30,30,30) !important;color:RGB('+colorArr.join('%,')+'%) !important;'};function createCSS(sel,decl,styleElem){var doc=document,h=doc.getElementsByTagName('head')[0],styleElem=styleElem;if(!styleElem){s=doc.createElement('style');s.setAttribute('type','text/css');styleElem=ie?doc.styleSheets[doc.styleSheets.length-1]:h.appendChild(s)};if(ie){styleElem.addRule(sel,decl)}else{styleElem.innerHTML='';styleElem.appendChild(doc.createTextNode(sel+' {'+decl+'}'))};return styleElem};function showTip(){var tipElem=doc.createElement('div'),body=doc.getElementsByTagName('body')[0];tipElem.innerHTML='=== 夜間模式開(kāi)啟。提示: q 或 w 可減少增加字體亮度 刷新取消===';tipElem.style.cssText='background-color:#3FA9FB !important;color:#fff !important;font-size:14px;height:20px;line-height:20px;position:fixed;left:0;top:0;text-align:center;width:100%;z-index:99999;';body.appendChild(tipElem);setTimeout(function(){body.removeChild(tipElem)},3000)}})();"><i class="icon-sign-blank"></i>夜間模式</a>

2. 網(wǎng)頁(yè)全屏

   document.getElementById("a_FullScreen").onclick = function () {
              
                
               
                requestFullScreen(document.documentElement);// 整個(gè)網(wǎng)頁(yè)
            };

            function requestFullScreen(element) {
                // 判斷各種瀏覽器,找到正確的方法
                var requestMethod = element.requestFullScreen || //W3C
                element.webkitRequestFullScreen ||    //Chrome等
                element.mozRequestFullScreen || //FireFox
                element.msRequestFullScreen; //IE11
                if (requestMethod) {
                    requestMethod.call(element);
                }
                else if (typeof window.ActiveXObject !== "undefined") {//for Internet Explorer
                    var wscript = new ActiveXObject("WScript.Shell");
                    if (wscript !== null) {
                        wscript.SendKeys("{F11}");
                    }
                }
            }

            //退出全屏 判斷瀏覽器種類
            function exitFull() {
                // 判斷各種瀏覽器,找到正確的方法
                var exitMethod = document.exitFullscreen || //W3C
                document.mozCancelFullScreen ||    //Chrome等
                document.webkitExitFullscreen || //FireFox
                document.webkitExitFullscreen; //IE11
                if (exitMethod) {
                    exitMethod.call(document);
                }
                else if (typeof window.ActiveXObject !== "undefined") {//for Internet Explorer
                    var wscript = new ActiveXObject("WScript.Shell");
                    if (wscript !== null) {
                        wscript.SendKeys("{F11}");
                    }
                }
            }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容