文章出處

Window.prototype.alert = function(){
  //創建一個大盒子
var box = document.createElement("div");
  //創建一個關閉按鈕
var button = document.createElement("button");
  //定義一個對象保存樣式
var boxName = { width:"500px", height:"180px", backgroundColor:"#f8f8f8", border:"1px solid #ccc", position:"absolute", top:"50%", left:"50%", margin:"-90px 0 0 -250px", zIndex:"999", textAlign:"center", lineHeight:"180px" }
  //給元素添加元素
for(var k in boxName){ box.style[k] = boxName[k]; }
  //把創建的元素添加到body中 document.body.appendChild(box);
  //把alert傳入的內容添加到box中
if(arguments[0]){ box.innerHTML = arguments[0]; } button.innerHTML = "關閉";
  //定義按鈕樣式
var btnName = { border:"1px solid #ccc", backgroundColor:"#fff", width:"70px", height:"30px", textAlign:"center", lineHeight:"30px", outline:"none", position:"absolute", bottom:"10px", right:"20px", } for(var j in btnName){ button.style[j] = btnName[j]; }
  //把按鈕添加到box中 box.appendChild(button);
  //給按鈕添加單擊事件 button.addEventListener(
"click",function(){ box.style.display = "none"; }) } alert("我的好朋友JavaScript```")

 

重寫console.log

console.log = (function(log){
    return function(){
        log.call(console,"hello:"+(arguments[0]||" "));
    }
}(console.log))
console.log("alert");

 


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()