<html>
<head>
<meta charset="UTF-8">
<title>啊啊啊啊</title>
<style>
*{
margin: 0;
padding: 0;
}
html,body{
width: 100%;
height: 100%;
}
.container{
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<iframe src="2.html" id="frame1" width="100%" height="100%" frameborder="no" border="0" marginwidth="0" marginheight="0"allowtransparency="yes"></iframe>
</body>
<script type="text/javascript">
var httpRequest = new XMLHttpRequest();//第一步:建立所需的对象
httpRequest.open('GET', '/webbaseinfo/isShow', true);//第二步:打开连接 将请求参数写在url中 ps:"http://localhost:8080/rest/xxx"
httpRequest.send();//第三步:发送请求 将请求参数写在URL中
/**
* 获取数据后的处理程序
*/
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var json = httpRequest.responseText;//获取到json字符串,还需解析
console.log(json);
if(json=="true"){
document.getElementById('frame1').src ="/news.html";
}else{
document.getElementById('frame1').src ="/not"
// window.location.href="/not";
}
}
};
</script>
</html>
动态iframe加载
最新推荐文章于 2024-04-29 17:01:02 发布