以上是被控制页面代码。被控制页面名称:l1r1.html
需要实现:
1、通过调用语句:“javascript:goleftURL('test3.html');”实现iframe id="left1" 中的src="test1.html"改变成src="test3.html"
2、通过条用语句:“javascript:gorightURL('test4.html');”实现iframe id="right1" s中的src="test2.html"改变成src="test4.html"
3、通过调用语句:“javascript:goallURL('test5.html','test6.html');”实现iframe id="left1" 中的src="test1.html"改变成src="test5.html"、实现iframe id="right1" 中的src="test2.html"改变成src="test6.html"
PS:需注意
1、调用语句是在test1.html、test2.html页面中使用。来控制l1r1.html中的iframe。
2、调用页面的(test1.html、test2.html)条件、传值、取值语句写在一个独立的JS中。l1r1.html的条件、传值、取值语句直接写在本页即可。
3、请各位大神帮忙写出具体实例代码,本人超级小二白。劳烦了
要有关系,没有关系只能通过服务器或者cookie,localstorage进行内容共享了,需要用到计时器定时检查cookie或者localstorage,你采纳我的帮写你个demo
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello</title>
</head>
<!-- <script src="/js/jquery.min.js"></script> -->
<script type="text/javascript">
function clickButton(){
var text = document.getElementById("name1").value;
var frame = document.getElementById('frame1');
frame.src="table.jsp?text="+text;
}
</script>
<body>
Hello ${name}
<br/><br/><br/><br/>
<span style="white-space:pre;"> </span><input id="name1" type="text"></input>
<span style="white-space:pre;"> </span><input id="buttton1" type="button" onclick="clickButton()" value="Click me"/>
<span style="white-space:pre;"> </span>
<span style="white-space:pre;"> </span><iframe src="table.jsp" id="frame1"
<span style="white-space:pre;"> </span>frameborder="0" marginheight="0" marginwidth="0" height="700" width="100%"></iframe>
</body>
</html>
-------------------------------------
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ page import="springbootjsp.springbootjspweb.config.SpringManager"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
<%@ page import="springbootjsp.springbootjspweb.service.HelloService"%>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>HELLO</title>
</head>
<body>
<%
String text = request.getParameter("text");
//HelloService helloService = SpringManager.getApplicationContext().getBean(HelloService.class);
%>
transport text from parent window is : <%=text %>
</body>
</html>
goUrl.js
function goleftURL(ul){
if(ul.length > 5){
parent.document.getElementById("left1").src = ul;
}
}
function gorightURL(ul){
if(ul.length > 5){
parent.document.getElementById("right1").src = ul;
}
}
function goallURL(ul1, ul2){
goleftURL(ul1);
gorightURL(ul2);
}