怎么使用JavaScript定時(shí)器制作彈窗小廣告

這篇“怎么使用JavaScript定時(shí)器制作彈窗小廣告”文章的知識(shí)點(diǎn)大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“怎么使用JavaScript定時(shí)器制作彈窗小廣告”文章吧。

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、成都微信小程序、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了天涯免費(fèi)建站歡迎大家使用!

具體代碼如下

<head>
 <meta charset="UTF-8">
 <title>Title</title>
 <style type="text/css">
 * {
  padding: 0;
  margin: 0;
 }
 li {
  list-style: none;
 }
 body {
  background: #940032;
 }

 #counter {
  width: 500px;
  height: 420px;
  background: #939;
  margin: 50px auto 0;
  position: relative;
 }

 #counter h3 {
  line-height: 42px;
  padding-left: 15px;
  font-size: 14px;
  font-family: arial;
  color: #ff3333;
 }

 #counter a {
  font-weight: normal;
  text-decoration: none;
  color: #ff3333;
 }

 #counter a:hover {
  text-decoration: underline;
 }

 #bg {
  width: 280px;
  height: 200px;
  border: 3px solid #680023;
  background: #990033;
  filter: alpha(opacity=80);
  opacity: 0.8;
  position: absolute;
  left: 50%;
  top: 115px;
  margin-left: -141px;
 }

 #counter_content {
  width: 250px;
  position: absolute;
  top: 130px;
  left: 130px;
  z-index: 1;
 }

 #counter_content h4 {
  margin-bottom: 10px;
 }

 #counter_content h4 input {
  border: none;
  width: 223px;
  height: 30px;
  line-height: 30px;
  padding: 0 10px;
  background: url(img/ico.png) no-repeat;
  text-align: right;
  color: #333;
  font-size: 14px;
  font-weight: bold;
 }

 #counter_content div {
  width: 250px;
 }

 #counter_content input {
  width: 60px;
  height: 30px;
  line-height: 30px;
  float: left;
  background: url(img/ico.png) no-repeat -303px 0;
  text-align: center;
  color: #fff;
  cursor: pointer;
  margin: 0 1px 4px 0;
  border: 0;
 }

 #counter_content div > input:hover {
  background: url(img/ico.png) no-repeat -243px 0;
 }

 #counter p {
  width: 500px;
  position: absolute;
  bottom: 20px;
  left: 0;
  color: #ff3333;
  text-align: center;
  font-size: 12px;
 }
 </style>
</head>
<body>
<div id="counter">
 <h3>簡易計(jì)算</h3>
 <div id="counter_content">
 <h4><input id="input1" type="text" value="0"/></h4>
 <div id="div1">
  <input type="button" value="7" onclick="kick('7')"/>
  <input type="button" value="8" onclick="kick('8')"/>
  <input type="button" value="9" onclick="kick('9')"/>
  <input type="button" value="+" onclick="kick('+')"/>
  <input type="button" value="4" onclick="kick('4')"/>
  <input type="button" value="5" onclick="kick('5')"/>
  <input type="button" value="6" onclick="kick('6')"/>
  <input type="button" value="-" onclick="kick('-')"/>
  <input type="button" value="1" onclick="kick('1')"/>
  <input type="button" value="2" onclick="kick('2')"/>
  <input type="button" value="3" onclick="kick('3')"/>
  <input type="button" value="*" onclick="kick('*')"/>
  <input type="button" value="0" onclick="kick('0')"/>
  <input type="button" value="C" onclick="kick('C')"/>
  <input type="button" value="=" onclick="kick('=')"/>
  <input type="button" value="/" onclick="kick('/')"/>
 </div>
 </div>
</div>
</body>
<script>
 var showInput = document.getElementById("input1");
 var isClear = false;
 var tempStr = "";
 var clacType = "";
 var isContinue = true;
 function kick(clickValue) {
 switch (clickValue) {
  case "=":
  if (tempStr != "" && clacType != "") {
   showInput.value = clac(tempStr, showInput.value, clacType);
   isContinue = false;
   clacType = "";
  }
  break;
  case "+":
  case "-":
  case "*":
  case "/":
  //如果預(yù)存的操作符不為空 表示表示連續(xù)操作
  if (clacType != "" && !isContinue) { //先執(zhí)行計(jì)算
   tempStr = clac(tempStr, showInput.value, clacType);
   isClear = true;
   clacType = clickValue;
  } else {
   tempStr = showInput.value; //點(diǎn)擊操作符之后 預(yù)存字符
   isClear = true;//表示點(diǎn)擊了操作符
   clacType = clickValue;//預(yù)存操作符
  }
  isContinue = true;
  break;
  case "C":
  showInput.value = "0";
  isClear = false;
  tempStr = "";
  clacType = "";
  break;
  default://普通的數(shù)字按鈕點(diǎn)擊
  showInput.value = showInput.value == "0" ? "" : showInput.value;
  isContinue = false;
  if (isClear) {
   showInput.value = "";
   showInput.value += clickValue;
   isClear = false;
  } else {
   showInput.value += clickValue;
  }
  break;
 }
 }


 function clac(num1, num2, type) {
 switch (type) {
  case "+":
  return Number(num1) + Number(num2);
  case "-":
  return Number(num1) - Number(num2);
  case "*":
  return Number(num1) * Number(num2);
  case "/":
  return Number(num1) / Number(num2);
  default:
  break;
 }
 }
 </script>

效果圖:

怎么使用JavaScript定時(shí)器制作彈窗小廣告

以上就是關(guān)于“怎么使用JavaScript定時(shí)器制作彈窗小廣告”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對大家有幫助,若想了解更多相關(guān)的知識(shí)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)頁標(biāo)題:怎么使用JavaScript定時(shí)器制作彈窗小廣告
網(wǎng)頁鏈接:http://muchs.cn/article40/piheeo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、網(wǎng)站制作、Google、網(wǎng)站收錄、微信公眾號(hào)、網(wǎng)站導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)