JS頁面隨機彈窗代碼 隨機彈窗加隨機不彈,這個是用戶要求需要實現:擊頁面任意地方,隨機50%的概率彈窗或者不彈窗,彈窗的話隨機彈設置的列表里面的其中一個域名。實現代碼如下:
<!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><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>JS頁面隨機彈窗代碼 隨機彈窗加隨機不彈</title><script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script><script>function RandomNumBoth(Min,Max){ var Range = Max - Min; var Rand = Math.random(); var num = Min + Math.round(Rand * Range); //四舍五入 return num;}$(function(){var urls = [ "http://www.abc.com","http://www.123.com"];var num=urls.length;var index=RandomNumBoth(0,num)var isClick=RandomNumBoth(1,2);document.onclick = function(){ if(isClick >=2){ //alert(index); window.open(urls[index],index); isClick = 1; }}})</script></head><body>JS頁面隨機彈窗代碼 隨機彈窗加隨機不彈</body></html>
效果演示
以上就是JS頁面隨機彈窗代碼 隨機彈窗加隨機不彈的全部內容,希望對大家的學習和解決疑問有所幫助,也希望大家多多支持武林網。新聞熱點
疑難解答