JavaScript不适用于HTML页面

时间:2014-08-14 14:47:07

标签: javascript html

我需要在页面上添加JavaScript代码段。

HTML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>

<script charset="windows-1251" type="text/javascript" src="http://www.ozon.ru/PartnerTwinerNew.aspx?revident=af76eb4c-d6c7-4708-807b-664db33ecae1" ></script>

</body>
</html>

如果您打开该页面并查看源代码,然后单击&#34; src&#34;链接,它显示了这个:

document.write(" <link rel=\"Stylesheet\" type=\"text/css\" href=\"//www.ozon.ru/styles/charger/style.css\" /> <link rel=\"Stylesheet\" type=\"text/css\" href=\"//www.ozon.ru/styles/charger/00.css\" />  ............... ")

1 个答案:

答案 0 :(得分:3)

它正常,demo显示。

我把代码片段

<script charset="windows-1251" type="text/javascript" src="http://www.ozon.ru/PartnerTwinerNew.aspx?revident=af76eb4c-d6c7-4708-807b-664db33ecae1" ></script>

在html框中输出以下内容:

http://static2.ozone.ru/multimedia/books_covers/l60/c120/1004121257.jpg

等等。

如果您不确定发生了什么,那么在开发者工具中检查控制台总是有用的。

请注意,使用html5,您可以替换此

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

用这个

<!doctype html>