为什么这个HTML不起作用? [英] Why this html doesn't work?

查看:81
本文介绍了为什么这个HTML不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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


< HTML>

< HEAD>

< META http-equiv ="内容型"含量=" text / html的; charset = UTF-8" / b $ b

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

<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"/


>
>



< TITLE> HTML到文本测试页< / TITLE>

< SCRIPT type =" text / javascript" src =" test.js" />

< SCRIPT type =" text / javascript">

function onload(){

提醒(aaa);

}

< / SCRIPT>

< / HEAD>

< BODY>

< DIV id =" case1">

< P> abc< / P>

< P> def< / P>

< / DIV>

< / BODY>

< / HTML>

test.js与html文件位于同一目录中。

警告对话框不会出现。

如果我删除包含test.js文件的行,则html文件

有效,否则即使test.js

是警告对话框也不会出现空的。

提前致谢。

<TITLE>HTML to Text Test Page</TITLE>
<SCRIPT type="text/javascript" src="test.js"/>
<SCRIPT type="text/javascript">
function onload(){
alert("aaa");
}
</SCRIPT>
</HEAD>
<BODY>
<DIV id="case1">
<P>abc</P>
<P>def</P>
</DIV>
</BODY>
</HTML>
The test.js is located in the same directory as that of the html file.
The alert dialog doesn''t appear.
If I remove the line that includes the test.js file, the html file
works, otherwise the alert dialog doesn''t appear even if the test.js
is empty.
Thanks in advance.

推荐答案

Scripsit ray:
Scripsit ray:

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



发布网址,而不是代码提取。

Post a URL, not a code extract.


< SCRIPT type =" text /的javascript" SRC =" test.js" />
<SCRIPT type="text/javascript" src="test.js"/>



不要混用HTML和XHTML。不要在网上使用XHTML,直到你知道XHTML实际上是什么。 (当你明白它的时候,你就不需要告诉他们不要在网上使用XHTML。)


具体来说,你呢?知道上述标记在(非XHTML)HTML中的意义

以及浏览器如何处理您的文档为HTML?

Don''t mix HTML and XHTML. Don''t use XHTML on the web until you
understand what XHTML actually is. (And when you do understand it, you
don''t need to be told not to use XHTML on the web.)

Specifically, do you know what the above tag means in (non-XHTML) HTML
and how it is processed by browsers treating your document as HTML?


< SCRIPT type =" text / javascript">

function onload(){

alert(" aaa");

}

< / SCRIPT>
<SCRIPT type="text/javascript">
function onload(){
alert("aaa");
}
</SCRIPT>



元素的内容在JavaScript中定义了一个函数。你是否希望在页面加载时调用(调用)函数
?为什么?


(你实际上没有剪切和粘贴_real_页面,是吗?这是

你应该发布网址的原因之一。 )

The content of the element defines a function in JavaScript. Do you
expect the function to be called (invoked) when the page is loaded? Why?

(You did not actually cut and paste the _real_ page, did you? This is
one of the reasons why you should post a URL.)


如果删除包含test.js文件的行,则html文件

有效,否则警告对话框不会即使test.js

为空,也会出现。
If I remove the line that includes the test.js file, the html file
works, otherwise the alert dialog doesn''t appear even if the test.js
is empty.



如果有效意味着执行了警报(aaa)调用,我不相信你.B
相信你。


-

Jukka K. Korpela(Yucca)
http: //www.cs.tut.fi/~jkorpela/

If "works" means that the alert("aaa") invocation is executed, I don''t
believe you.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


ray写道:
ray wrote:

< META http-equiv =" Content-Type"含量=" text / html的; charset = UTF-8" />
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"/ >



根据doctype声明,您的文档是HTML文档。

META元素是一个没有结束标记的空元素。

在XML中,空元素需要一个(fwd斜杠)终止符。

在XHTML中,open元素需要(space + fwd slash)终止符。

在HTML中META元素应如此:

< META http-equiv =" Content-Type"含量=" text / html的; charset = UTF-8">

Your document is an HTML document per the doctype declaration.
The META element is an empty element without a closing tag.
In XML, empty elements require a (fwd slash) terminator.
In XHTML, open elements require (space + fwd slash) terminator.
In HTML the META element should look so:
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">


< SCRIPT type =" text / javascript" SRC =" test.js" />
<SCRIPT type="text/javascript" src="test.js"/>



SCRIPT元素需要HTML和XHTML中的结束标记,

是否为空。

在XML中(我相信,因为没有进入XML),一个空元素关闭了

标记,并且开始标记添加了一个(fwd斜杠)终结符。

In HTML SCRIPT元素应如下所示:

< SCRIPT type =" text / javascript" src =" test.js">< / SCRIPT>

The SCRIPT element requires a closing tag in both HTML and XHTML,
whether empty or not.
In XML (I believe, since not into XML), an empty element has the closing
tag dropped and the opening tag has a (fwd slash) terminator added.
In HTML the SCRIPT element should look so:
<SCRIPT type="text/javascript" src="test.js"></SCRIPT>


如果删除包含test.js文件的行,则html文件

有效,否则即使test.js

为空,也不会出现警告对话框。
If I remove the line that includes the test.js file, the html file
works, otherwise the alert dialog doesn''t appear even if the test.js
is empty.



使用结束标签它可以工作。


-

Gus

With the closing tag it works.

--
Gus


On 26 Mai,04:53,ray< hanl ... @ gmail.comwrote:
On 26 Mai, 04:53, ray <hanl...@gmail.comwrote:

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

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


< HTML>

*< HEAD>

* *< META http -equiv = QUOT;内容类型"含量=" text / html的; charset = UTF-8" /


* *< TITLE> HTML到文本测试页< / TITLE>

* *< SCRIPT type =" ;文本/ JavaScript的" SRC =" test.js" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
* * * * * "http://www.w3.org/TR/html4/strict.dtd">

<HTML>
* <HEAD>
* * <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/

* * <TITLE>HTML to Text Test Page</TITLE>
* * <SCRIPT type="text/javascript" src="test.js"/>



您应该使用正确的文档类型。


阅读htmldog.com是最佳做法。

You should use a proper document type.

It''s considered best practise to read htmldog.com.


* *< SCRIPT type =" text / javascript">

* * * function onload(){

* * *提醒(" aaa");

* * *}

* *< / SCRIPT>

*< / HEAD>

*< BODY>

* *< DIV id =" case1">

* * *< P> abc< / P>

* * *< P> def< / P>

* *< / DIV>

*< / BODY>

< / HTML>

test.js与html文件位于同一目录中。

警告对话框不会出现。

如果我删除包含test.js文件的行,则html文件

有效,否则即使test.js

为空,也不会出现警告对话框。

提前感谢。
* * <SCRIPT type="text/javascript">
* * * function onload(){
* * * alert("aaa");
* * * }
* * </SCRIPT>
* </HEAD>
* <BODY>
* * <DIV id="case1">
* * * <P>abc</P>
* * * <P>def</P>
* * </DIV>
* </BODY>
</HTML>
The test.js is located in the same directory as that of the html file.
The alert dialog doesn''t appear.
If I remove the line that includes the test.js file, the html file
works, otherwise the alert dialog doesn''t appear even if the test.js
is empty.
Thanks in advance.


这篇关于为什么这个HTML不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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