function show(){
return document.selection.createRange().text
}
</Script>
<input type="text" value="无忧脚本">
<input type="button" value="show" onclick="window.alert(show())">
或者
<script language="javascript">
function i()
{
if(window.document.selection)&&(window.document.selection.type="text")
var sel=window.document.selection.createRange()
window.alert(sel)
}
</script>
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--" name=form1>
<p><a href=javascript:i()>bbb</a></p>
<p><textarea rows="17" name="myfile" cols="108" id="myfile"></textarea></p>
</form>
<!doctype html><html>
<head>
<meta charset="utf-8">
<title>计算1+1/3+1/5+...+1/(2n-1)累加和</title>
<script type="text/javascript">
function compute(){
var n = document.getElementById("n").value
var result = document.getElementById("result")
var sum = 0
for(var i=1 i<=n i++){
sum += 1/(2*i-1)
}
result.value = sum
}
</script>
</head>
<body>
<div style="width:300pxheight:200pxborder:groove 8px #009900line-height:2emmargin:50px autotext-align:center" >
<h3 style="padding:10px color:#0000cc">计算累加和</h3>
<form>
输入数N:
<input id="n" type="text" value="" />
<br/>
&nbsp累加和&nbsp:
<input id="result" type="text" value="" />
<br/>
<input id="sum" type="button" value="计算累加和" onClick="compute()" />
<input id="reset" type="reset" value="重置" />
</form>
</div>
</body>
</html>
找人做作业才给5分啊,再说不怕你们老师上网搜么?很容易暴露的。
代码如下:var field1 = document.getElementById('field1')
var field2 = document.getElementById('field2')
var result = document.getElementById('result')
result.innerHTML = '<div style="width:' + field1.value + 'pxheight:' + field2.value+ 'px"></div>'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)