注册 登录
编程论坛 JavaScript论坛

求助一个问题,为什么功能实现不了

yinhaixiang 发布于 2011-07-31 18:29, 325 次点击
<html>
<head>
<title>无标题文档</title>
<style type="text/css">
</style>
<script type="text/javascript">
function showLength() {
var texts = document.form1.strings.value.length;
document.form2.lengths.value = texts;
}

function htm_fontcolor() {
var texts = document.form1.strings.value;
texts = texts.fontcolor("blue");
document.form2.lengths.value = texts;
}

function htm_big() {
var texts = document.form1.strings.value;
texts = text.big();
document.form2.lengths.value = texts;
}

function bigToSmall() {
var texts = document.form1.strings.value;
texts = texts.toLowerCase();
document.form2.lengths.value = texts;
}

function htm_bold() {
var texts = document.form1.strings.value;
texts = texts.bold();
document.form2.lengths.value = texts;
}

</script>
</head>

<body>
<center>
<form name="form1">
请输入内容:<br/>
<textarea name="strings" rows="5" cols="30"></textarea>
</form>
<form name="form2">
<input type="button" value="显示字符串长度" onClick="showLength()"><br/>
<input type="button" value="<big>标记" onClick="htm_big()"><br/>
<input type="button" value="全部转换为小写" onClick="bigToSmall()"><br/>
<input type="text" name="lengths" size="40"><p>
<input type="button" value="粗体显示" onClick="htm_bold()">
<input type="button" value="显示为蓝色字体" onClick="htm_fontcolor()">
</form>
</center>

</body>
</html>

为什么大写转小写功能可以实现,粗体显示和显示为蓝色字体功能实现不了呢,谢谢各位
1 回复
#2
aspic2011-08-03 16:43
程序代码:
<html>
<head>
<title>无标题文档</title>
<script type="text/javascript">
function showLength() {
    var texts = document.form1.strings.value.length;
    document.getElementById("lblResult").innerHTML = texts;
}
function htm_fontcolor() {
    var texts = document.form1.strings.value;
    texts = texts.fontcolor("blue");
    document.getElementById("lblResult").innerHTML = texts;
}
function htm_big() {
    var texts = document.form1.strings.value;
    texts = "<big>" + texts + "</big>";
    document.getElementById("lblResult").innerHTML = texts;
    alert(document.getElementById("lblResult").innerHTML)
}
function bigToSmall() {
    var texts = document.form1.strings.value;
    texts = texts.toLowerCase();
    document.getElementById("lblResult").innerHTML = texts;
}
function htm_bold() {
    var texts = document.form1.strings.value;
    texts = texts.bold();
    document.getElementById("lblResult").innerHTML = texts;
}
</script>
</head>

<body>
<center>
<form name="form1">
    请输入内容:<br/><textarea name="strings" rows="5" cols="30"></textarea>
</form>
<form name="form2">
    <input type="button" value="显示字符串长度" onClick="showLength()"><br/>
    <input type="button" value="<big>标记" onClick="htm_big()"><br/>
    <input type="button" value="全部转换为小写" onClick="bigToSmall()"><br/>
    <span id="lblResult"></span><br>
    <input type="button" value="粗体显示" onClick="htm_bold()">
    <input type="button" value="显示为蓝色字体" onClick="htm_fontcolor()">
</form>
</center>
</body>
</html>



[ 本帖最后由 aspic 于 2011-8-3 16:44 编辑 ]
1