document.write方法不要在頁面加載完之后調(diào)用,否則就會(huì)出現(xiàn)這樣的問題
大方ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!
把
function makedot(x,y){ //畫點(diǎn)函數(shù)
document.write("div style='height:1px;position:absolute;left:"+x+"px;top:"+y+"px;width:1px;background:#f00;overflow:hidden'/div")
}
改成
function makedot(x,y){ //畫點(diǎn)函數(shù)
$('body').append("div style='height:1px;position:absolute;left:"+x+"px;top:"+y+"px;width:1px;background:#f00;overflow:hidden'/div")
}
可以呀,只要他們倆之間畫很多的小點(diǎn)就是一條直線啦,哈哈,用循環(huán)就可以啦,至于點(diǎn)的位置嘛,只要有初中的數(shù)學(xué)就可以搞定,我就不說了,顏色和粗度只要設(shè)置小點(diǎn)的style就可以啦,至于小點(diǎn)嘛可不能用英文里的句號(hào)(.),哪樣會(huì)產(chǎn)生編差,因?yàn)樗辉谡?而在底部,可以用(●),雖然大了點(diǎn),但可以變小,也可以自已成為畫一個(gè)圖,哈哈,,,,,,,,,
html xmlns:v="urn:schemas-microsoft-com:vml"
HEAD
META http-equiv="Content-Type" content="text/html;Charset=gb2312"
titlevml實(shí)例/title
STYLE
v\:*{behavior:url(#default#VML);}/*聲明V為VML變量*/
/STYLE
SCRIPT LANGUAGE="JavaScript"
var x,y,a,b;
function drawline(fromX,fromY,toX,toY){
var strElement= "v:Line id='line_"+fromX+"_"+fromY+"_"+toX+"_"+toY+"' from='" + fromX + "," + fromY + "' to='" + toX + "," + toY + "' strokecolor='red'/v:Line";
var newPoint = document.createElement(strElement);
document.getElementById("map").appendChild(newPoint);
}
function draw(){
if(x==undefinedb==undefined){x=window.event.x;y=window.event.y;return false;}
a=window.event.x;b=window.event.y;
drawline(x,y,a,b)
x=a;y=b;
}
function draws(){
if(x==undefinedb==undefined){return false;}
if(x==window.event.xb==window.event.y){return false;}
if(document.getElementById("TempLine")){document.getElementById("TempLine").outerHTML=""}
var strElement= "v:Line id='TempLine' from='" + x + "," + y + "' to='" + window.event.x + "," + window.event.y + "' strokecolor='red'/v:Line";
var newPoint = document.createElement(strElement);
document.getElementById("map").appendChild(newPoint);
}
/SCRIPT
/HEAD
BODY
table border="1" align="center"
tr
tddiv id="map" style="width:600px;height:500px;background-color:#cccccc;position:relative;" onmousedown="draw();" onmousemove="draws()"/div/td
/tr
/table
/body
/html
以上代碼僅支持IE瀏覽器。
js中波浪線運(yùn)算符"~"的作用是將數(shù)字轉(zhuǎn)化為有符號(hào)32位整數(shù)并作位取反, 位取反即把數(shù)字轉(zhuǎn)換為2進(jìn)制補(bǔ)碼然后把0和1反轉(zhuǎn). 對(duì)一個(gè)數(shù)字取反2次會(huì)變成原來的數(shù)字, 于是雙波浪線的作用就是把一個(gè)小數(shù)舍棄小數(shù)點(diǎn)轉(zhuǎn)換為整數(shù), 在數(shù)字較小轉(zhuǎn)換為32位整數(shù)時(shí)不會(huì)溢出的情況下可以當(dāng)作Math.floor的偷懶寫法. 不過更一般的寫法是"num | 0", 即位或0, 在位運(yùn)算上不會(huì)改變數(shù)字但可以快速的轉(zhuǎn)換為整數(shù), 在各種將數(shù)字轉(zhuǎn)換為整數(shù)的寫法中位或0速度最快
網(wǎng)頁標(biāo)題:javascript線,js畫線條
分享路徑:http://aaarwkj.com/article8/dssgiip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、建站公司、網(wǎng)站導(dǎo)航、定制網(wǎng)站、品牌網(wǎng)站制作、App設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)