個人對魅族手機也經常關注,覺得設計感比較贊,昨天剛MX4發布完,今天去官網看看,點擊預定發現如圖:
呵呵,沒想到這么“火爆”,細想下點擊之后彈窗的速度怎么會這么快,終於細想....不會是....
用firebug查看下網絡請求
於是“呵呵呵”拆穿了吧!
看下腳本:
var focusImgTime = null; var dom = document.getElementById("waitPreorder"); var opacity = document.getElementById("opacity"); var focusImg = document.getElementById("focusImg"); var currentImg = 1; var isFocusImg = true; var startFocusImgTime = null; var startBooking = function() { var mobliePreorder = document.getElementById("mobliePreorder"); mobliePreorder.onclick = function() { var r = Math.ceil(Math.random() * 10); r > 5 ? getJsonpRequest() : getFocusImg()//這里就是關鍵的地方了 ,隨機一個數字決定你是否直接跳到預定還是彈“火爆“窗體 } }; var getJsonpRequest = function() { var url = "http://count.booking.meizu.com/count.php?jsonpcallback=getActivityData"; var script = document.createElement('script'); script.setAttribute('src', url); document.getElementsByTagName('head')[0].appendChild(script)//腳本請求返回結果調用下面getActivityData的方法 };
//處理結果返回預定的跳轉地址 var getActivityData = function(data) { if (typeof data[0] != 'undefined' && typeof data[0]['result'] != 'undefined' && data[0]['result'] == '1') { startFocusImgTime = null; window.location.href = data[0]['msg'] } else { isFocusImg && getFocusImg() } };
//彈窗 var getFocusImg = function() { isFocusImg = false; var clientHeight = document.documentElement.clientHeight; var bodyHeight = document.body.clientHeight; dom.style.display = "block"; opacity.style.width = document.documentElement.clientWidth; opacity.style.height = bodyHeight + "px"; focusImg.style.top = (clientHeight - 612) / 2 + "px"; focusImg.style.left = (document.documentElement.clientWidth - 992) / 2 + "px"; startFocusImgTime = setInterval(function() { getJsonpRequest() }, 5000)//倒數5秒后請求跳轉 }; startBooking();
相信大家一目了然了,其實沒什么技術含量,雖然只是商家想促銷的的手段,只是感覺被欺騙了就不爽了,認真做好產品自然會獲得用戶!
這里向魅族寫官網腳本的同行表示下歉意,因為想你做的更好,所以才會關注!