JS 设置线条样式控件 我在做一个VML画线功能,想要动态设置线的样式,哪位能提供设置样式的控件??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接JS就可以,如下:1,假设有样式:<style type="text/css"> .cur01{background-color:#00CCFF; border:1px solid red; color:#FF3300; font-size:15px; font-weight:bold;}</style>2,假设有HTML:<div id="box01">This is a box</div><input type="button" name="btn01" value="Test" onClick="javascript:setClass('box01','cur01');">3,JS给ID=box1的DIV设置样式:<script language="javascript" type="text/javascript">function setClass(objID,className){var o=document.getElementById(objID);var cName=className;o.className=cName;}</script> 自己对应参数加就行了/** * VML graphic *///// monitor phaserfunction oval(r){ return '<rv:oval style="top:'+(180-r)+'; left:'+(180-r)+'; width:'+(2*r)+'; height:'+(2*r)+';position:absolute;" filled="false" strokecolor="gray" strokeweight="1" />';}function backRect(ofsetY, ofsetX, strkclr, w, h){ return '<rv:rect style="top:'+ofsetY+'; left:'+ofsetX+'; width:'+w+'px; height:'+h+'px; position:absolute;" strokecolor="'+strkclr+'" strokeweight="1" />';}function back(ofset, strkclr, w, h, fillclr){ return '<rv:rect style="top:'+ofset+'; left:'+ofset+'; width:'+w+'px; height:'+h+'px; position:absolute;" strokecolor="'+strkclr+'" strokeweight="1"'+fillclr+' />';}function line(x1,y1,x2,y2, lnclr, lnsw){ return '<rv:line style="position:absolute;" from="'+x1+','+y1+'" to="'+x2+','+y2+'" strokecolor="'+lnclr+'" strokeweight="'+lnsw+'" />';}function convLine(x1,y1,x2,y2, lnclr, lnsw){ return arrowLine(x1+VEC_S, y1+VEC_S, x2+VEC_S, (-1*y2)+VEC_S, lnclr, lnsw);}function arrowLine(x1,y1,x2,y2, lnclr, lnsw){ return '<rv:line style="position:absolute;" from="'+x1+','+y1+'" to="'+x2+','+y2+'" strokecolor="'+lnclr+'" strokeweight="'+lnsw+'"><rv:stroke dashstyle="solid" endarrow="classic" /></rv:line>';}function convDotLine(x1,y1,x2,y2, lnclr, lnsw){ return arrowDotLine(x1+VEC_S, (-1*y1)+VEC_S, x2+VEC_S, (-1*y2)+VEC_S, lnclr, lnsw);}function arrowDotLine(x1,y1,x2,y2, lnclr, lnsw){ return '<rv:line style="position:absolute;" from="'+x1+','+y1+'" to="'+x2+','+y2+'" strokecolor="'+lnclr+'" strokeweight="'+lnsw+'"><rv:stroke dashstyle="dash" endarrow="classic" /></rv:line>';}/** * 锛� startangle銆乪ndangle */function arc(r, start, end){ return '<rv:arc style="top:'+(240-r)+'; left:'+(180-r)+'; width:'+(2*r)+'; height:'+(2*r)+';position:absolute;" startangle="'+start+'" endangle="'+end+'" strokecolor="gray" filled="false" strokeweight="1" />';}//// monitor harmfunction polyline(polyY, polyX, strkclr, lnsw){ var ptStr = ""; for(i=0; i<polyY.length; i++){ ptStr += polyX[i] + "," + polyY[i] + " "; } return '<rv:polyline style="position:absolute;" points="'+ptStr+'" strokecolor="'+strkclr+'" strokeweight="'+lnsw+'" filled="false"/>';}function polyline2(polyY, polyX, ps, pe, strkclr, lnsw){ var ptStr = ""; for(i=ps; i<pe; i++){ ptStr += polyX[i] + "," + polyY[i] + " "; } return '<rv:polyline style="position:absolute;" points="'+ptStr+'" strokecolor="'+strkclr+'" strokeweight="'+lnsw+'" filled="false"/>';}function rect(ofsetY, ofsetX, strkclr, w, h, fillclr){ return '<rv:rect style="position:absolute; top:'+ofsetY+'; left:'+ofsetX+'; width:'+w+'px; height:'+h+'px;" fillcolor="'+fillclr+'" strokecolor="'+strkclr+'" strokeweight="1" />';}///// pqvif listfunction dotLine(x1,y1,x2,y2, lnclr, lnsw){ return '<rv:line style="position:absolute;" from="'+x1+','+y1+'" to="'+x2+','+y2+'" strokecolor="'+lnclr+'" strokeweight="'+lnsw+'"><rv:stroke dashstyle="dot" endarrow="none" /></rv:line>';}function setVString(x1,y1,x2,y2, str, lnclr, lnsw){ x2 += 0.05; return '<rv:line style=\"position:absolute;\" from="'+x1+','+y1+'\" to="'+x2+','+y2+'" strokecolor=\"'+lnclr+'\" strokeweight=\"'+lnsw+'\" filled=\"true\"><rv:path textpathok=\"true\" /><rv:fill type=\"solid\" color=\"'+lnclr+'\" /><rv:textpath on=\"true\" string=\"'+str+'" style=\"font:normal normal normal 14pt \'verdana\'\"/></rv:line>'; // verdana, Arial Black, Sans-Serif, gradient, color2c="'+lnclr+'"} 给个完整的:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head><style type="text/css">.cur01{background-color:#00CCFF; border:1px solid red; font-family:verdana; color:#FF3300; font-size:15px; font-weight:bold; padding:10px;}</style><body><div id="box01">This is a box </div> <input type="button" name="btn01" value="Test" onClick="javascript:setClass('box01','cur01');"> <script language="javascript" type="text/javascript"> function setClass(objID,className){ var o=document.getElementById(objID); var cName=className; o.className=cName; } </script></body></html> 一道js题(散分),说下思路即可 求仿照webqq图标排列的demo 【急切】汉字字符串作为javascript函数的参数,为什么没有反应呢?(与php的混合应用) 怎么根据链接改变样式? 如何判断JavaScript,window.open()弹出窗口已经存在? 一个关于javascript读取xml的问题 救命呀,表单欠套问题 难题,在firefox下,如何获取inputtext的值那?在线等 网页制作高手帮忙 js轮薄涂封装 javascript function1中的变量名不能和function2的方法名相同吗?请指教 求js自动生成一个编号算法
<style type="text/css">
.cur01{background-color:#00CCFF; border:1px solid red; color:#FF3300; font-size:15px; font-weight:bold;}
</style>2,假设有HTML:
<div id="box01">This is a box</div>
<input type="button" name="btn01" value="Test" onClick="javascript:setClass('box01','cur01');">3,JS给ID=box1的DIV设置样式:
<script language="javascript" type="text/javascript">
function setClass(objID,className){
var o=document.getElementById(objID);
var cName=className;
o.className=cName;
}
</script>
* VML graphic
*///// monitor phaser
function oval(r)
{
return '<rv:oval style="top:'+(180-r)+'; left:'+(180-r)+'; width:'+(2*r)+'; height:'+(2*r)+';position:absolute;" filled="false" strokecolor="gray" strokeweight="1" />';
}function backRect(ofsetY, ofsetX, strkclr, w, h)
{
return '<rv:rect style="top:'+ofsetY+'; left:'+ofsetX+'; width:'+w+'px; height:'+h+'px; position:absolute;" strokecolor="'+strkclr+'" strokeweight="1" />';
}function back(ofset, strkclr, w, h, fillclr)
{
return '<rv:rect style="top:'+ofset+'; left:'+ofset+'; width:'+w+'px; height:'+h+'px; position:absolute;" strokecolor="'+strkclr+'" strokeweight="1"'+fillclr+' />';
}function line(x1,y1,x2,y2, lnclr, lnsw)
{
return '<rv:line style="position:absolute;" from="'+x1+','+y1+'" to="'+x2+','+y2+'" strokecolor="'+lnclr+'" strokeweight="'+lnsw+'" />';
}function convLine(x1,y1,x2,y2, lnclr, lnsw){
return arrowLine(x1+VEC_S, y1+VEC_S, x2+VEC_S, (-1*y2)+VEC_S, lnclr, lnsw);
}function arrowLine(x1,y1,x2,y2, lnclr, lnsw){
return '<rv:line style="position:absolute;" from="'+x1+','+y1+'" to="'+x2+','+y2+'" strokecolor="'+lnclr+'" strokeweight="'+lnsw+'"><rv:stroke dashstyle="solid" endarrow="classic" /></rv:line>';
}function convDotLine(x1,y1,x2,y2, lnclr, lnsw)
{
return arrowDotLine(x1+VEC_S, (-1*y1)+VEC_S, x2+VEC_S, (-1*y2)+VEC_S, lnclr, lnsw);
}function arrowDotLine(x1,y1,x2,y2, lnclr, lnsw)
{
return '<rv:line style="position:absolute;" from="'+x1+','+y1+'" to="'+x2+','+y2+'" strokecolor="'+lnclr+'" strokeweight="'+lnsw+'"><rv:stroke dashstyle="dash" endarrow="classic" /></rv:line>';
}
/**
* 锛� startangle銆乪ndangle
*/
function arc(r, start, end)
{
return '<rv:arc style="top:'+(240-r)+'; left:'+(180-r)+'; width:'+(2*r)+'; height:'+(2*r)+';position:absolute;" startangle="'+start+'" endangle="'+end+'" strokecolor="gray" filled="false" strokeweight="1" />';
}//// monitor harmfunction polyline(polyY, polyX, strkclr, lnsw)
{
var ptStr = "";
for(i=0; i<polyY.length; i++){
ptStr += polyX[i] + "," + polyY[i] + " ";
}
return '<rv:polyline style="position:absolute;" points="'+ptStr+'" strokecolor="'+strkclr+'" strokeweight="'+lnsw+'" filled="false"/>';
}
function polyline2(polyY, polyX, ps, pe, strkclr, lnsw)
{
var ptStr = "";
for(i=ps; i<pe; i++){
ptStr += polyX[i] + "," + polyY[i] + " ";
}
return '<rv:polyline style="position:absolute;" points="'+ptStr+'" strokecolor="'+strkclr+'" strokeweight="'+lnsw+'" filled="false"/>';
}
function rect(ofsetY, ofsetX, strkclr, w, h, fillclr)
{
return '<rv:rect style="position:absolute; top:'+ofsetY+'; left:'+ofsetX+'; width:'+w+'px; height:'+h+'px;" fillcolor="'+fillclr+'" strokecolor="'+strkclr+'" strokeweight="1" />';
}///// pqvif list
function dotLine(x1,y1,x2,y2, lnclr, lnsw){
return '<rv:line style="position:absolute;" from="'+x1+','+y1+'" to="'+x2+','+y2+'" strokecolor="'+lnclr+'" strokeweight="'+lnsw+'"><rv:stroke dashstyle="dot" endarrow="none" /></rv:line>';
}function setVString(x1,y1,x2,y2, str, lnclr, lnsw){
x2 += 0.05;
return '<rv:line style=\"position:absolute;\" from="'+x1+','+y1+'\" to="'+x2+','+y2+'" strokecolor=\"'+lnclr+'\" strokeweight=\"'+lnsw+'\" filled=\"true\"><rv:path textpathok=\"true\" /><rv:fill type=\"solid\" color=\"'+lnclr+'\" /><rv:textpath on=\"true\" string=\"'+str+'" style=\"font:normal normal normal 14pt \'verdana\'\"/></rv:line>';
// verdana, Arial Black, Sans-Serif, gradient, color2c="'+lnclr+'"
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<style type="text/css">
.cur01{background-color:#00CCFF; border:1px solid red; font-family:verdana; color:#FF3300;
font-size:15px; font-weight:bold; padding:10px;}
</style>
<body>
<div id="box01">This is a box </div>
<input type="button" name="btn01" value="Test" onClick="javascript:setClass('box01','cur01');">
<script language="javascript" type="text/javascript">
function setClass(objID,className){
var o=document.getElementById(objID);
var cName=className;
o.className=cName;
}
</script>
</body>
</html>