本文目錄一覽:
- 1、如何用js實現調用手機攝像頭掃描條形碼然後帶出條形碼的值到文本框
- 2、html5, js實現安卓手機在微信瀏覽器中下載APP問題,如圖
- 3、jquery九宮格抽獎怎麼控制停止位置
- 4、九宮格抽獎外框燈的閃爍怎麼用js實現
- 5、js 九宮格怎麼實現順時針旋轉抽獎
如何用js實現調用手機攝像頭掃描條形碼然後帶出條形碼的值到文本框
1、開啟溝子的方法代碼。
2、指定輸入間隔為300毫秒以內時為連續輸入方法代碼。
3、記錄按鍵信息方法代碼。
4、事件的狀態代碼方法。
5、因為條形碼中只有數字和部分符號,所以基本可以不用考慮鍵盤狀態或組合鍵的情況,但二維碼就不能不考慮了。
6、可以使用_keydown.Contains(160)判斷是否按下了Shift鍵,然後使用ShiftChar方法來獲取最終的按鍵對應字元至於結果保存,我使用了一個數組ListListEventMsg,對每次輸入都單獨進行記錄。
html5, js實現安卓手機在微信瀏覽器中下載APP問題,如圖
一款JS+html5轉盤抽獎代碼網頁特效,該特效代碼基於html5canvas技術實現,點擊開始旋轉按鈕,轉盤就會快速旋轉,停止旋轉後,所在區域就是中獎項目。獎項可以自定義。請用支持HTML5+CSS3主流瀏覽器預覽效果。(兼容測試:FireFox、Chrome、Safari、Opera等支持HTML5/CSS3瀏覽器)使用方法:1、調用CSS樣式:2、添加HTML代碼:將之間的html和js代碼;放在之間。
jquery九宮格抽獎怎麼控制停止位置
參考下面代碼
!–效果html開始–
div id=”lottery”
table border=”0″ cellpadding=”0″ cellspacing=”0″
tr
td class=”lottery-unit lottery-unit-0″img src=”images/1.png”/td
td class=”lottery-unit lottery-unit-1″img src=”images/2.png”/td
td class=”lottery-unit lottery-unit-2″img src=”images/4.png”/td
td class=”lottery-unit lottery-unit-3″img src=”images/3.png”/td
/tr
tr
td class=”lottery-unit lottery-unit-11″img src=”images/7.png”/td
td colspan=”2″ rowspan=”2″a href=”#”/a/td
td class=”lottery-unit lottery-unit-4″img src=”images/5.png”/td
/tr
tr
td class=”lottery-unit lottery-unit-10″img src=”images/1.png”/td
td class=”lottery-unit lottery-unit-5″img src=”images/6.png”/td
/tr
tr
td class=”lottery-unit lottery-unit-9″img src=”images/3.png”/td
td class=”lottery-unit lottery-unit-8″img src=”images/6.png”/td
td class=”lottery-unit lottery-unit-7″img src=”images/8.png”/td
td class=”lottery-unit lottery-unit-6″img src=”images/7.png”/td
/tr
/table
/div
js部分
script type=”text/javascript” src=”jquery-1.8.3.min.js”/script
script type=”text/javascript”
var lottery={
index:-1, //當前轉動到哪個位置,起點位置
count:0, //總共有多少個位置
timer:0, //setTimeout的ID,用clearTimeout清除
speed:20, //初始轉動速度
times:0, //轉動次數
cycle:50, //轉動基本次數:即至少需要轉動多少次再進入抽獎環節
prize:-1, //中獎位置
init:function(id){
if ($(“#”+id).find(“.lottery-unit”).length0) {
$lottery = $(“#”+id);
$units = $lottery.find(“.lottery-unit”);
this.obj = $lottery;
this.count = $units.length;
$lottery.find(“.lottery-unit-“+this.index).addClass(“active”);
};
},
roll:function(){
var index = this.index;
var count = this.count;
var lottery = this.obj;
$(lottery).find(“.lottery-unit-“+index).removeClass(“active”);
index += 1;
if (indexcount-1) {
index = 0;
};
$(lottery).find(“.lottery-unit-“+index).addClass(“active”);
this.index=index;
return false;
},
stop:function(index){
this.prize=index;
return false;
}
};
function roll(){
lottery.times += 1;
lottery.roll();
if (lottery.times lottery.cycle+10 lottery.prize==lottery.index) {
clearTimeout(lottery.timer);
lottery.prize=-1;
lottery.times=0;
click=false;
}else{
if (lottery.timeslottery.cycle) {
lottery.speed -= 10;
}else if(lottery.times==lottery.cycle) {
var index = Math.random()*(lottery.count)|0;
lottery.prize = index;
}else{
if (lottery.times lottery.cycle+10 ((lottery.prize==0 lottery.index==7) || lottery.prize==lottery.index+1)) {
lottery.speed += 110;
}else{
lottery.speed += 20;
}
}
if (lottery.speed40) {
lottery.speed=40;
};
//console.log(lottery.times+’^^^^^^’+lottery.speed+’^^^^^^^’+lottery.prize);
lottery.timer = setTimeout(roll,lottery.speed);
}
return false;
}
var click=false;
window.onload=function(){
lottery.init(‘lottery’);
$(“#lottery a”).click(function(){
if (click) {
return false;
}else{
lottery.speed=100;
roll();
click=true;
return false;
}
});
};
/script
九宮格抽獎外框燈的閃爍怎麼用js實現
用setinterval ,每隔1秒或者2秒,然後寫一個自增的 i,i是幾就讓第幾個框亮,當i到9,就把i 置成1,至於框亮,可以改變框的背景色來處理。用js修改。
js 九宮格怎麼實現順時針旋轉抽獎
機制說明:
1、通過定義lottery-unit來控制節點的個數及索引;
2、通過設置lottery.crcle來定義需要轉動的基本次數,在這個次數內,定時器的時間間隔不斷遞減,知道某個具體的數值;
3、當外界設置了lottery.prize即中獎目標的索引後,檢查噹噹前轉動次數已經大於lottery.crcle,這個過程開始遞減定時器的時間間隔,直到lottery.prize等於lottery.prize,這時候初始化所有參數。
原創文章,作者:簡單一點,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/128689.html