问题...帮助 [英] Problem...help

查看:65
本文介绍了问题...帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能告诉我这里的问题在哪里吗?我无法得到平方()>

函数才能正常工作...它应该将平方值放入

iframe区域。


谢谢,

Ed


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN">

< html>

< head>

< script type =" text / javascript" ;>

//平方根

函数squareroot()

{

x = document.root

data = x.num.value

var sqr = Math.sqrt(data)

parent.sqrt.document.write(sqr)

}

//物品平方

功能平方()

{

x = document.square

data = x.num.value

var sum = data * data

parent.squaredframe.document.write()

}

// Tanget

函数正切()

{

x = document.tangent

data = x.num.value

var tan = Math.tan(data)

parent.tangentframe.document.write(tan)

}

//刷新值

函数刷新()

{

location.reload(sqrt)

location.reload(squaredframe)

location.reload(tangentframe)

}

< / script>

< / head>


< body>

< table width =" 100%" border =" 1">

< tr>

< td width =" 73%" height =" 50"

< form name =" root">

输入一个数字来计算值的平方根。 />
< input name =" num2"类型= QUOT;文本" ID = QUOT; NUM"大小= QUOT; 10" maxlength =" 10">

< input name =" button"类型= QUOT按钮" onClick =" squareroot()"

value =" Compute">

< / form>< / td>

< td width =" 27%" height =" 50">< iframe name =" sqrt"宽度= QUOT; 100%QUOT; height =" 50"

frameborder =" 0" scrolling =" no">< / iframe>< / td>

< / tr>

< tr>

< td height =" 50">

< form name =" square">

输入一个数字来计算值的平方。

< input name =" num3"类型= QUOT;文本" ID = QUOT; NUM2"大小= QUOT; 10" maxlength =" 10">

< input name =" button2"类型= QUOT按钮" onClick =" squared()"

value =" Compute">

< / form>< / td>

< td>< iframe name =" squaredframe"宽度= QUOT; 100%QUOT;高度= QUOT; 50" frameborder =" 0"

scrolling =" no">< / iframe>< / td>

< / tr>

< tr>

< td height =" 50">

< form name =" tangent">

输入一个数字来计算值的tanget。

< input name =" num"类型= QUOT;文本" ID = QUOT; NUM3"大小= QUOT; 10" maxlength =" 10">

< input name =" button3"类型= QUOT按钮" onClick =" tangent()"

value =" Compute">

< / form>< / td>

< td>< iframe name =" tangentframe"宽度= QUOT; 100%QUOT;高度= QUOT; 50" frameborder =" 0"

scrolling =" no">< / iframe>< / td>

< / tr>

< / table>

< div align =" right">

< form name =" refresh">

点击刷新计算新值。

< input type =" button"的onClick = QUOT;刷新()" value ="刷新值">

< / form>

< / div>

< / body>

< / html>

Can someone tell me where the problem here is? I can''t get the "squared()"
function to work properly...it supposed to put the squared value into the
iframe area.

Thanks,
Ed

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
//Square Root
function squareroot()
{
x=document.root
data=x.num.value
var sqr=Math.sqrt(data)
parent.sqrt.document.write(sqr)
}
//Squared of an item
function squared()
{
x=document.square
data=x.num.value
var sum=data*data
parent.squaredframe.document.write()
}
//Tanget
function tangent()
{
x=document.tangent
data=x.num.value
var tan=Math.tan(data)
parent.tangentframe.document.write(tan)
}
//Refresh Values
function refresh()
{
location.reload(sqrt)
location.reload(squaredframe)
location.reload(tangentframe)
}
</script>
</head>

<body>
<table width="100%" border="1">
<tr>
<td width="73%" height="50">
<form name="root">
Type in a number to compute the square root of the value.
<input name="num2" type="text" id="num" size="10" maxlength="10">
<input name="button" type="button" onClick="squareroot()"
value="Compute">
</form></td>
<td width="27%" height="50"><iframe name="sqrt" width="100%" height="50"
frameborder="0" scrolling="no"></iframe></td>
</tr>
<tr>
<td height="50">
<form name="square">
Type in a number to compute the square of the value.
<input name="num3" type="text" id="num2" size="10" maxlength="10">
<input name="button2" type="button" onClick="squared()"
value="Compute">
</form></td>
<td><iframe name="squaredframe" width="100%" height="50" frameborder="0"
scrolling="no"></iframe></td>
</tr>
<tr>
<td height="50">
<form name="tangent">
Type in a number to compute the tanget of the value.
<input name="num" type="text" id="num3" size="10" maxlength="10">
<input name="button3" type="button" onClick="tangent()"
value="Compute">
</form></td>
<td><iframe name="tangentframe" width="100%" height="50" frameborder="0"
scrolling="no"></iframe></td>
</tr>
</table>
<div align="right">
<form name="refresh">
Hit refresh to compute new values.
<input type="button" onClick="refresh()" value="Refresh Values">
</form>
</div>
</body>
</html>

推荐答案

Ed Blinn< eb **** @ sbcglobal.net>写道:
Ed Blinn <eb****@sbcglobal.net> writes:
有人能告诉我这里的问题在哪里吗?我无法使squared()
函数正常工作......它应该将平方值放入
iframe区域。


其他功能是否有效? (不,不在我的浏览器中)

<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN">


此DOCTYPE触发怪癖模式。不应该为

怪癖模式制作新页面。

函数squareroot()
{
x = document.root


我更喜欢

var x = document.forms [''root''];

data = x.num.value
< br $>


var data = x.elements [''num'']。value;


它更容易阅读,并保证在所有W3C DOM

浏览器中也可以使用。

var sqr = Math.sqrt(data)


为何选择sqr局部变量,但不是x。或数据?

parent.sqrt.document.write(sqr)


sqrt帧不是父文档的子帧,而是这个

文件(这就是为什么其他功能对我不起作用的原因,我在iframe中测试过它们b / b
,所以父母不等于到自我。


frames [''sqrt'']。document.write(sqr);

函数平方()
{
x = document.square
data = x.num.value


表格document.forms [''square'']"并不是一个名为

num的元素。它有name =" num3"和id =" num2"。


....< form name =" square">
....< input name =" num3"类型= QUOT;文本" ID = QUOT; NUM2"大小= QUOT; 10" maxlength =" 10"
Can someone tell me where the problem here is? I can''t get the "squared()"
function to work properly...it supposed to put the squared value into the
iframe area.
Does the other functions work? (No, not in my browsers)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
This DOCTYPE triggers quirks mode. New pages should not be made for
quirks mode.
function squareroot()
{
x=document.root
I prefer
var x = document.forms[''root''];
data=x.num.value
and
var data = x.elements[''num''].value;

It is much easier to read, and is guaranteed to work in all W3C DOM
browsers too.
var sqr=Math.sqrt(data)
Why make "sqr" a local variable, but not "x" or "data"?
parent.sqrt.document.write(sqr)
The sqrt frame is not a subframe of the parent document, but of this
document (that is why the other functions didn''t work for me, I tested
them in an iframe, so "parent" isn''t equal to "self").

frames[''sqrt''].document.write(sqr);
function squared()
{
x=document.square
data=x.num.value
The form "document.forms[''square'']" doesn''t hae an element called
"num". It has name="num3" and id="num2".

.... <form name="square"> .... <input name="num3" type="text" id="num2" size="10" maxlength="10">




/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

Art D''HTML:< URL:http://www.infimum.dk /HTML/randomArtSplit.html>

''没有判断的信仰只会降低精神神圣。''



/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D''HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
''Faith without judgement merely degrades the spirit divine.''


JRS:在文章中< he **********@hotpop.com> ;,见于

news:comp.lang.javascript,Lasse Reichstein Nielsen< lr*@hotpop.com>

发布于2003年9月16日星期二02:32:17: -
JRS: In article <he**********@hotpop.com>, seen in
news:comp.lang.javascript, Lasse Reichstein Nielsen <lr*@hotpop.com>
posted at Tue, 16 Sep 2003 02:32:17 :-
<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



此DOCTYPE触发怪癖模式。不应该为
怪癖模式制作新页面。



This DOCTYPE triggers quirks mode. New pages should not be made for
quirks mode.




那么,你推荐什么?


ISTM应该选择<!DOCTYPE ...> (或没有),然后

然后调整代码直到它验证(这涉及选择一个

验证器)。


-

?约翰斯托克顿,英国萨里。 ?@merlyn.demon.co.uk Turnpike v4.00 IE 4?

< URL:http://jibbering.com/faq/> Jim Ley的新闻常见问题解答:comp.lang.javascript

< URL:http://www.merlyn.demon.co.uk/js-index.htm> JS数学,日期,来源。

< URL:http://www.merlyn.demon.co.uk/> TP / BP / Delphi / JS /& c。,FAQ主题,链接。



What, then, do you recommend?

ISTM that one should choose a <!DOCTYPE ...> (or not to have one), and
then adjust the code until it validates (which involves choosing a
validator).

--
? John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ?
<URL:http://jibbering.com/faq/> Jim Ley''s FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.


John Stockton博士< sp ** @ merlyn.demon.co.uk>写道:
Dr John Stockton <sp**@merlyn.demon.co.uk> writes:
此DOCTYPE触发怪癖模式。不应该为
怪癖模式制作新页面。
你推荐什么?
This DOCTYPE triggers quirks mode. New pages should not be made for
quirks mode.
What, then, do you recommend?




我建议决定HTML的版本,在这种情况下版本4.01

Transitional很好,并为

添加了一个文档类型声明,即将新浏览器置于标准模式的版本。

那将是:


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN"

" http://www.w3.org/TR/html4/transitional.dtd">


如果有疑问,请为DTD添加适当的URL,该URL始终为

标准模式。


Opera的页面,包含MSDN和Mozilla的链接:

< URL:http:/ /www.opera.com/docs/specs/doctype/>

ISTM应该选择一个<!DOCTYPE ...> (或没有),然后
然后调整代码直到它验证(这涉及选择
验证器)。



I recommend deciding on a verions of HTML, in this case version 4.01
Transitional is fine, and the adding a document type declaration for
that version that puts new browsers into standards mode.
That would be:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">

If in doubt, add the appropriate URL for the DTD, that always gives
standards mode.

Opera''s page about it, with links to MSDN and Mozilla:
<URL:http://www.opera.com/docs/specs/doctype/>
ISTM that one should choose a <!DOCTYPE ...> (or not to have one), and
then adjust the code until it validates (which involves choosing a
validator).




如果全部DOCTYPE确实定义了HTML版本,那么只要你告诉验证者要检查哪些HTML

版本,你就可以没有它。$ br $ b。 >

由于DOCTYPE声明确实是双重职责,因为

的触发器向后(或错误)与页面直接写入

CSS /渲染IE 4的错误,新页面不应该写成没有DOCTYPE或带有触发怪癖模式的DOCTYPE的



当然,我相信写作达到官方标准。其他人

不在乎,并乐意写一些针对浏览器的页面,这些页面可以模仿IE4(目前包括后来的IE,Mozilla和Opera 7,以及

也许是其他人。)


这些人也住在洞穴里吃根(或者我只是用b / b
引导Dogbert)。 br />

/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

Art D''HTML:< URL:http://www.infimum.dk/HTML/randomArtSplit.html>

''没有判断的信仰只会降低精神神圣。''



If all the DOCTYPE did was define the HTML version, then you could
probably do without it, as long as you tell the validator what HTML
version to check against.

Since the DOCTYPE declaration does double duty as a trigger for
backwards (or bugwards) compatabilty with pages written directly to
the CSS/rendering bugs of IE 4, new pages should not be written
without a DOCTYPE or with a DOCTYPE that triggers quirks mode.

Ofcourse, I believe in writing to the official standards. Other people
don''t care, and will gladly write pages targeted at browsers which can
emulate IE4 (currently includes later IEs, Mozilla and Opera 7, and
maybe others).

These people also live in caves and eat roots (or maybe I am just
channeling Dogbert).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D''HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
''Faith without judgement merely degrades the spirit divine.''


这篇关于问题...帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆