<table width="99%" height="540px">
<tr>
<td width="99%" align="left" valign="top" style="border:1px solid #B4C9C6;height:180px;width:750px;background-color: #fff;">
<div style=" overflow:auto;height:100%;">
<s:form id="searchForm" target="myframe" action="searchSelectedQuestion" namespace="/data" onsubmit="return checkInput();">
<input type="submit" value="搜索" name="advencesearch" id="search-submit" style="margin-top: 10px"/>
<table class="t2" id="showQuestion">
</table>
</s:form>
</div>
</td>
</tr>
<tr>
<td style="border:1px solid #B4C9C6;height:340px;background-color: #fff;">
<iframe onload="initPage()" width="100%" height="100%" frameborder="0" id="myframe" name="myframe" scrolling="auto">
</iframe>
</td>
</tr>
</table>
这样操作试过吗?
1、你先删除s标签,修改为<form id="searchForm" target="myframe" action="searchSelectedQuestion" namespace="/data" onsubmit="return checkInput();">
<input type="submit" value="搜索" name="advencesearch" id="search-submit" style="margin-top: 10px"/>
<table class="t2" id="showQuestion">
</table>
</form>2、假设iframe里面的内容为:<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<style type="text/css">
</style>
<script type="text/javascript">
//js直接实现
function testFunc(){
//获取父窗口的表单ID
var form = window.parent.document.getElementById("searchForm");
//form.属性名 //获取form的属性
//提交表单
form.submit();
}
//jQuery方法实现
$(function(){
$('#test').click(function(){
var form = $('#searchForm',parent.document);
//jquery对象转换为js对象
form.get(0).submit();
});
})
</script>
</head>
<body>
<input type="button" value="test" id="test" onclick="testFunc();">
</body>
</html>这样当你点击按钮的时候,上面的表单就会提交了
1、js代码(1)第一种方法
格式:window.frames["iframe的name值"].document.getElementById("iframe中控件的ID").click();
//window.frames["mainIframe"].document.getElementById("iTextValue").value;
//触发iframe中的元素的单击事件
//window.frames["mainIframe"].document.getElementById("iTestClick").click();(2)第二种方法
格式:
var obj=document.getElementById("iframe的ID").contentWindow;
var ifmObj=obj.document.getElementById("iframe中控件的ID");
ifmObj.click();
//var obj=document.getElementById("mainIframe").contentWindow;
//var ifmObj=obj.document.getElementById("iTestClick");
//ifmObj.click();2、jquery代码(1)第一种方法
格式:$("#iframe的ID").contents().find("#iframe中的控件ID").click();
//$("#mainIframe").contents().find("#iTextValue").val();(2)第二种方法
格式:$("#iframe中的控件ID", window.frames("frame的name").document).click();
//$("#iTextValue",window.frames["mainIframe"].document).val();在iframe中获取父窗口的元素
1、js代码格式:window.parent.document.getElementById("父窗口的元素ID").click();
//window.parent.document.getElementById("testClick").click();2、jquery代码格式:$('#父窗口中的元素ID', parent.document).click();
//$('#textValue', parent.document).val();
top 顶层窗口
因为这个s标签,其它地方有用到,改了就影响到其它功能了。
jsp标签最终会转化为HTML标签,js可以对jsp标签进行操作。