如图所示,大家帮忙看一下javascript里top是什么意思?

<script>
var tobj=document.getElementById("top");
//单击让top链接到left网页
tobj.onclick=function(){
window.top.location.href="left.html";
}
</script>

问:不明白window.top这里的top是框架最上面那一横条,可是不明白是这一横条本身系统规定的叫top,还是
因为在设置框架的时候<frame src="top.html" name="top">时候,把这框架陈为top的原因。自己运行了下,好像与name没关系,但是不敢确定,有顶朦朦胧胧。求大家指教

  • http://img2.mukewang.com/624e9a6800013bf103070113.jpg


www说
浏览 340回答 2
2回答

拉风的咖菲猫

"window.location.href"、"location.href"是本页面跳转."parent.location.href" 是上一层页面跳转."top.location.href" 是最外层的页面跳转.举例说明:如果A,B,C,D都是html,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写"window.location.href"、"location.href":D页面跳转"parent.location.href":C页面跳转"top.location.href":A页面跳转如果D页面中有form的话,<form>: form提交后D页面跳转<form target="_blank">: form提交后弹出新页面<form target="_parent">: form提交后C页面跳转<form target="_top"> : form提交后A页面跳转如果访问的是iframe里面的页面,重新加载最外层的页面<html><head><title></title><script language="javascript">function escapeFrame(){if (window.top.location.href != window.location.href) {window.top.location.reload();}}</script></head><body onload="escapeFrame()"><iframe src="b.html" ></iframe></body></html>

Smart猫小萌

你看document.getElementById,就是表示根据id查找,也就是说有个id是top的元素,也就是你找到这一句id="top"
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript