前端页面以框架的形式展示,处于任意一页面中定位出父页面路径,调用parent对象的location属性。
frame.html
<html>
<frameset cols="25%,50%,25%">
<frame src="frame_a.html"/>
<frame src="frame_b.html"/>
<frame src="frame_c.html"/>
</frameset>
<html>
frame_a.html
<html>
<head>
<title>a</title>
<script>
var _parent = window.parent;
alert(_parent.location);
</script>
</head>
<body>
A
</body>
</html>
frame_b.html
<html>
<head>
<title>b</title>
</head>
<body>
B
</body>
</html>
frame_c.html
<html>
<head>
<title>c</title>
</head>
<body>
C
</body>
</html>