JavaScript与网页设计

来源:百度知道 编辑:UC知道 时间:2024/06/19 10:28:37
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language=javascript type=text/javascript>
<!--
var str="This is an anchor";
str=str.anchor("anchor");
document.write("<div style='top:900px;left:400px;positon:absolute'>"+str+"</div>");
-->
</script>
</head>
<body>
<a href=#anchor>转跳到str</a>
</body>

你的doctype是xhtml transitional,但是你网页的内容根本是不符合要求的
script标签里面怎么能放html注释?这个会让你的脚本无法执行
所有的属性都应该有双引号
charset应该尽可能使用utf-8
str.anchor方法未定义
不要用document.write输出

试试把 position 放到 left 前边?因为我记得微软给的文档里说先赋 position 才有 'layout',试试不一定对