框架指向页面中提交到action
action返回的页面 想跳出框架
但是返回页面不执行js
输出语句都已执行fanhui.jsp<html>
<head>
<script type="text/javascript">
<!--<%System.out.println("aaaaaaaaaaa"); %>
alert("cccccccccc");
window.open('home.do','_top');
<%System.out.println("bbbbbbbbbbbbb"); %>
//-->
</script>
</head>
<body>
</body>
</html>
action返回的页面 想跳出框架
但是返回页面不执行js
输出语句都已执行fanhui.jsp<html>
<head>
<script type="text/javascript">
<!--<%System.out.println("aaaaaaaaaaa"); %>
alert("cccccccccc");
window.open('home.do','_top');
<%System.out.println("bbbbbbbbbbbbb"); %>
//-->
</script>
</head>
<body>
</body>
</html>
<html>
<head>
<script type="text/javascript"> alert("cccccccccc");
window.open('home.do','_top');
</script>
</head>
<body>
</body>
</html>我去掉你的注释能够运行啊.
<head>
<script type="text/javascript">
<!--
var a = "<%System.out.println("aaaaaaaaaaa"); %>"
alert(a);
window.open('home.do','_top');
var b = "<%System.out.println("bbbbbbbbbbbbb"); %>"
//-->
</script>
</head>
<body>
</body>
</html>即可
只是执行输出语句 alert语句 open语句都没执行 不知为什么 难道和在框架中有关吗 打开父窗口 我的open语句对吗
<head>
<script type="text/javascript">
<!--
var aa ="<% System.out.println('aaaaaaaaaaa'); %>"
alert("cccccccccc");
window.open('home.do','_top');
var bb = "<% System.out.println('bbbbbbbbbbbbb'); %>"
//-->
</script>
</head>
<body>
</body>
</html>
-------
这样也可以啊,open语句也有执行
2,有javascript代码但被注释
<head>
<script type="text/javascript">
function openNew() {
window.open("home.do","_self");
}</script>
</head>
<body onload="openNew();">
</body>
</html>我写成这样也不行 js在框架中 不能打开窗口吗
不过你这样做并不能跳出框架. 它只会在_top中打开home.do.
建议你试一下window.top.location.href='home.do';
我这里是<html>
<head>
<script type="text/javascript">
function openNew() {
alert("========");
} </script>
</head>
<body onload="openNew();">
</body>
</html> alert都没执行啊
框架指向页面中提交到action
action返回的页面 想跳出框架
但是返回页面不执行js
输出语句都已执行 fanhui.jsp <html>
<head>
<script type="text/javascript">
alert("cccccccccc");
window.open('home.do','_top');
</script>
</head>
<body>
</body> alert都没执行
</html>
我试了不行 主要是js语句不执行 alert都不执行
<html>
<head>
<script type="text/javascript"> alert("cccccccccc");
window.open('home.do','_top');
</script>
</head>
<body>
</body>
</html>
建议:
看看字符是否有中文的等,导致JS无法运行,看看是否有JS错误
另,JS里面的<-- //-->不会对JS运行有影响