此 HTML 代码片段中的 onclick 函数在哪里定义?
我在 HTMLCodeTutorial.com 上阅读了此代码:
<FORM>
<TABLE BORDER CELLPADDING=3>
<TR>
<TD><NOBR>radius: <INPUT NAME="Circle_radius" SIZE=4></NOBR></TD>
<TD><INPUT TYPE=BUTTON OnClick="Circle_calc(this.form);" VALUE="calculate"></TD>
<TD ALIGN=RIGHT BGCOLOR="#AACCFF">
<NOBR>circumference: <INPUT NAME="Circle_circumference" SIZE=9></NOBR><BR>
<NOBR>area: <INPUT NAME="Circle_area" SIZE=9></NOBR></TD>
</TR>
</TABLE>
</FORM>
我无法理解 OnClick= “Circle_calc(this.form);”
Circle_calc(this.form)
未在任何地方定义。这个功能如何运作?它是 HTML 中的内置函数吗?
I read this code on HTMLCodeTutorial.com:
<FORM>
<TABLE BORDER CELLPADDING=3>
<TR>
<TD><NOBR>radius: <INPUT NAME="Circle_radius" SIZE=4></NOBR></TD>
<TD><INPUT TYPE=BUTTON OnClick="Circle_calc(this.form);" VALUE="calculate"></TD>
<TD ALIGN=RIGHT BGCOLOR="#AACCFF">
<NOBR>circumference: <INPUT NAME="Circle_circumference" SIZE=9></NOBR><BR>
<NOBR>area: <INPUT NAME="Circle_area" SIZE=9></NOBR></TD>
</TR>
</TABLE>
</FORM>
I can’t understand OnClick="Circle_calc(this.form);"
Circle_calc(this.form)
isn't defined anywhere. How does this function work? Is it a built-in function in HTML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
它不是内置的。如果你看一下源代码,它的定义是:
It's not built-in. If you look at the source code, it's defined as:
不幸的是,这是一个相当蹩脚的教程,使用了过时的技术和非标准的 HTML 元素。
Circle_calc 不是内置函数...教程只是忽略了定义它,或者表明它是在其他地方定义的。
强烈建议您找到另一个网站来学习教程,但不幸的是没有一个网站可以推荐,因为我有一段时间不需要一个网站:S
Unfortunately, that's a pretty crappy tutorial using outmoded techniques and non-standard HTML elements.
Circle_calc
is not a builtin function... the tutorial has simply neglected to define it, or indicate that it is defined elsewhere.Strongly suggest you find another site for your tutorials, but unfortunately have none to recommend as I haven't needed one in a while :S
我认为他们非常顽皮,
如果您在该页面上查看页面源代码,并查看他们完成表单的方式,那么您将看到以下内容:
正如您所看到的,您现在在上下文中拥有 HTML 代码,您实际上可以看到 HTML 执行的脚本。由于脚本位于 HTML 文件内,因此您不需要在 HTML 文件顶部进行导入(如果这是正确的短语)来告诉它要使用哪个脚本文件。
另外,我强烈建议使用 W3c 学校教程,它们要好得多,可以在这里找到: http://www.w3schools.com/w3c/w3c_html.asp
They have been quite naughty methinks,
If you do a view page source on that page, and look at the way THEY'VE done the form, then you'll see this:
As you can see, you now have the HTML code in context, and you can actually see the script that the HTML executes. And as the script is inside the HTML file, you wouldn't need to have an import (if that's the right phrase) at the top of your HTML file telling it which script file to use.
Also I would strongly recommend using the W3c Schools tutorials, they're miles better and they can be found here: http://www.w3schools.com/w3c/w3c_html.asp
实际上该函数已定义,只是教程代码中未显示 - 请查看源代码以找到它。
Actually the function is defined, it just isn't showed in the tutorial code - look at the source to find it.
在教程的开头指出:
该函数在页面的源代码中定义:
该函数接受表单作为参数,JavaScript 函数将使用该参数对文本中的值执行读/写操作表单的字段。
我希望这有帮助。
In the beginning of the tutorial it is stated:
The function is defined in the source code of the page:
The function accepts the form as an argument that will be used by the JavaScript function to perform read/write operations over the values in the text fields of the form.
I hope this helps.