如何在jsp页面中添加颜色选择器

如何在jsp页面中添加颜色选择器,第1张

<html>

<head>

<SCRIPT>

function fnInit(){

for (i=0i<document.all.lengthi++)

document.all(i).unselectable = "on"

}

var sInitColor = null

function callColorDlg(){

if (sInitColor == null)

//display color dialog box

var sColor = dlgHelper.ChooseColorDlg()

else

var sColor = dlgHelper.ChooseColorDlg(sInitColor)

//change decimal to hex

sColor = sColor.toString(16)

//add extra zeroes if hex number is less than 6 digits

if (sColor.length <6) {

var sTempString = "000000".substring(0,6-sColor.length)

sColor = sTempString.concat(sColor)

}

//change color of the text in the div

oDiv.style.color= sColor

sInitColor = sColor

}

</SCRIPT>

</HEAD>

<BODY onload="fnInit()">

<H1>Choose Font Colors Sample</H1>

<DIV CLASS="desbar">

<P>This example demonstrates the features of

Microsoft? Internet Explorer that enable users to edit the content

of an HTML element directly from the browser.</P>

<P>This HTML editor is a <B>DIV</B>element set to be content-editable. You can choose the font color you want to use, or create custom colors.</P>

<DIV STYLE="padding:10pxbackground-color:#eeeeeeborder:2px solid #cccccc">

<BUTTON ID="ofntColor" title="Choose Font Color"

onclick="callColorDlg()">Choose Font color</BUTTON>

<br>

<br>

<DIV id=oDiv CONTENTEDITABLE ALIGN=left STYLE="height:100

background-color:whitefont-size:15ptfont-family:Arialpadding:10

border:2px inset #eeeeeeoverflow:auto">

Click the button to choose a font color using the choose color dialog.

</DIV>

</DIV>

<br>

<br>

<!--Create the Dialog Helper Object-->

<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>

</body>

</html>

您可以按照以下步骤来设置超链接的字体颜色:

1、在JSP文件中,定义一个样式表。

2、在需要添加超链接的地方,添加超链接标签。

3、在超链接标签中,添加刚才定义的样式表。

4、即可通过style属性设置了超链接的字体颜色为红色。

思路:将字符串拆分为字符数组,循环 *** 作此数组:用随机数(数组,如随机数1-10,对应不同的颜色),为每个字符添加颜色代码<font color="color[i]"></font>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11742983.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存