JavaScript 之 页面跳转及Frame动态加载

一、页面跳转

  JS跳转大概有以下五种方式:

1、跳转到B页面

<script language="javascript" type="text/javascript">
  window.location.href="B.html";
</script>

2、返回上一个页面

<script language="javascript">
    window.history.back(-1);
</script>

3、跳转到B页面

<script language="javascript">
    window.navigate("B.html");
</script>

4、跳转到B页面

<script language="JavaScript">
    self.location=’B.html’;
</script>

5、跳转到B页面

<script language="javascript">
    top.location=’B.html’;
</script>

二、Frame动态加载

页面代码实例

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>123</title>
</head>
<frameset rows="80,*" cols="*" frameborder="no" border="0" framespacing="0">
  <frame src="top.html" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
  <frameset cols="45%,*" frameborder="no" border="0" framespacing="0">
    <frame src="left.html" name="leftFrame" scrolling="AUTO" noresize="noresize" id="leftFrame" title="leftFrame" />
   <frameset rows="10%,*" cols="*" frameborder="1" border="1" framespacing="0">     <frame src="right_top.html" name="right_topFrame" id="right_topFrame" title="right_topFrame" />      <frame src="" name="right_bottomFrame" id="right_bottomFrame" title="right_bottomFrame" />    </frameset> </frameset> </frameset> <noframes>
  <
body></body> </noframes>
</
html>

页面跳转JS:

window.top.right_bottomFrame.location.href = "xxxx.htm";
window.parent.right_bottomFrame.location.href = "xxxx.htm";
document.getElementById("对应的ID号").src="path/xxxx.htm"
window.parent.document.getElementById("right_bottomFrame").src="xxx.htm";
原文地址:https://www.cnblogs.com/xinaixia/p/5085537.html