一、打印页面出错原因
重点是“try…catch”语句的运用。try语句用来运行代码,当代码有错误发生时,则转到catch语句继续执行。在catch语句中,使用“e.description”获取错误信息的描述,然后通过“document.write”方法,将错误信息显示在页面上。
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>标题页</title>
<script language="javascript">
function getError()
{
try
{
x =new test; //产生错误
}
catch(e)
{
document.write(e.description) //打印错误结果
}
}
</script>
</head>
<body onload="getError()" >
</body>
</html>
二、IE调用其他网页
一个页面可以使用iframe来加载另一个页面,但有些IE是禁止使用框架的,所以本例使用另外一个方法,实现在当前页中调用另一个网页。重点是object标签的使用。其type属性是“text/x-scriptlet”,其中“x-scriptlet”是IE的一个插件。data属性表示要加载的数据。
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>标题页</title>
</head>
<body>
<object type="text/x-scriptlet" width="150" height="100" data="http://www.baidu.com">
</object>
</body>
</html>
--------------------------------------
版权声明:本文为【PythonJsGo】博主的原创文章,同步在微信【猿小猴子】公众号平台,转载请附上原文出处链接及本声明。