一个陈旧而没有解决的问题,问了3个月了,没有答案!

big_fish 2006-03-10 09:52:50
有两个jsp页面,分别为
eventlist.jsp(列表页面,用来显示一组记录,以下简称list),
query.jsp(查询页面,用来输入查询条件,并且把条件传递给list页面,以下简称query)

在list中有段代码用来弹出(注意:是弹出)quey,代码如下:
function query()
{
var strShape;
var ret= window.open("query.jsp","query");
}

在query中,输入完查询条件,点“查询”按钮,执行search()方法:

function search(){
window.opener.form1.chTopic.value=chTopic.value;
window.opener.form1.chAddress.value=chAddress.value;
window.opener.form1.chLeader.value=chLeader.value;
window.opener.form1.submit();
window.close();
}

此方法把输入的查询条件传给后面的list窗体,并且把list窗体提交,把自己(也就是query)关闭!
----------------------------------------------------------------------------------
现在的问题是,如何保证list中弹出的query总在最前,即query不关闭,list就不能获得光标,
因为我们的系统以前都是这么写的,这样的页面有几千个,如果在list中使用showModalDialog()
弹出页面,我们的修改量非常大,几乎所有的页面都要修改,所以不想使用此办法!
另外window.open所带的一个参数为alwaysRaised,可保证弹出窗体总在最前,但是这个参数ie不支持,只有netscape navigator支持,所以也不能用;
还有一个在弹出的窗体query中,使用onBlur="self.focus()",可以保证最前,但是query页面不能输入任何数据,所以也不行,现在请大家帮我想想办法,从修改量尽可能最小的角度考虑,100分赠送!

谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢!
...全文
150 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ibiswang 2006-03-10
  • 打赏
  • 举报
回复
:),还是不要加上面的吧,还是原来的正确的,不然会有些小Bug.

也就是说如下:



list.html
================================================================
<html>
<body>
<div id="query" onclick="window.open('query.html','query');" style="width:80px;background-color:red;cursor:hand;">Query</div>
<div id="info">hello</div>

<input type="text" id="txt1"><br/>
<input type="text" id="txt2"><br/>
<input type="text" id="txt3"><br/>
<input type="text" id="txt4"><br/>
<input type="text" id="txt5"><br/>
<input type="text" id="txt6"><br/>
</body>
</html>

query.html
==================================================================
<html>
<script language="javascript">
function search(){
window.opener.info.innerText=info.innerText;
window.opener.txt1.value=txt1.value;
window.opener.txt2.value=txt2.value;
window.opener.txt3.value=txt3.value;
window.opener.txt4.value=txt4.value;
window.opener.txt5.value=txt5.value;

window.close();
}

function selfonBlur() {

if (!info.hasmouse){ self.focus(); return;}

setTimeout("selfonBlur()", 5);
}
</script>
<body onBlur="selfonBlur();" onload="self.focus();info.hasmouse=true;" onmouseover="this.style.color='green'; info.hasmouse=true;" onmouseout='this.style.color="blue"; info.hasmouse=false;'>

<div id="search" onclick="search();" style="width:80px;background-color:red;cursor:hand;">Search</div>
<div id="info">Copied from query page.</div>

<input type="text" id="txt1"><br/>
<input type="text" id="txt2"><br/>
<input type="text" id="txt3"><br/>
<input type="text" id="txt4"><br/>
<input type="text" id="txt5"><br/>
<input type="text" id="txt6"><br/>
</div>
</body>
</html>
ibiswang 2006-03-10
  • 打赏
  • 举报
回复
Sorry,其中有部分代码需要调整一下,否则Dead loop:


function selfonBlur() {

if (!info.hasmouse){ self.focus(); return;}

setTimeout("selfonBlur()", 5);
}

改为:

var tryCounter=0;
function selfonBlur() {

if (!info.hasmouse){ self.focus(); tryCounter=0;return;}

if (tryCounter<2) {
tryCounter++;
setTimeout("selfonBlur()", 1);
}
}
ibiswang 2006-03-10
  • 打赏
  • 举报
回复
我试后是可以的,下面是代码,你试下:

list.html
================================================================
<html>
<body>
<div id="query" onclick="window.open('query.html','query');" style="width:80px;background-color:red;cursor:hand;">Query</div>
<div id="info">hello</div>

<input type="text" id="txt1"><br>
<input type="text" id="txt2"><br>
<input type="text" id="txt3"><br>
<input type="text" id="txt4"><br>
<input type="text" id="txt5"><br>
<input type="text" id="txt6"><br>
</body>
</html>

query.html
==================================================================
<html>
<script language="javascript">
function search(){
window.opener.info.innerText=info.innerText;
window.opener.txt1.value=txt1.value;
window.opener.txt2.value=txt2.value;
window.opener.txt3.value=txt3.value;
window.opener.txt4.value=txt4.value;
window.opener.txt5.value=txt5.value;

window.close();
}

function selfonBlur() {

if (!info.hasmouse){ self.focus(); return;}

setTimeout("selfonBlur()", 5);
}
</script>
<body onBlur="selfonBlur();" onload="self.focus();info.hasmouse=true;" onmouseover="this.style.color='green'; info.hasmouse=true;" onmouseout='this.style.color="blue"; info.hasmouse=false;'>

<div id="search" onclick="search();" style="width:80px;background-color:red;cursor:hand;">Search</div>
<div id="info">Copied from query page.</div>

<input type="text" id="txt1"><br>
<input type="text" id="txt2"><br>
<input type="text" id="txt3"><br>
<input type="text" id="txt4"><br>
<input type="text" id="txt5"><br>
<input type="text" id="txt6"><br>
</div>
</body>
</html>


big_fish 2006-03-10
  • 打赏
  • 举报
回复
pdvv(我爱花猫) ( ) 信誉:100 2006-03-10 10:37:00 得分: 0

对你的说法表示怀疑
------------------
用你所说的方法,form1.c.focus();还是不灵啊,郁闷
飞翔的大麦茬 2006-03-10
  • 打赏
  • 举报
回复
按你的要求不好解决
建议还是用showModalDialog()吧
单独写成一个方法在一个JS文件中,然后在每个页面中引入,这样是好的习惯
以后修改就方便了
pdvv 2006-03-10
  • 打赏
  • 举报
回复
对你的说法表示怀疑

a.html:

<html>
<body>
<form name="form1">
<input type=text name="a" value="dddd">
<input type=text name="b" value="dddd">
<input type=text name="c" value="dddd">

<input type=button value="query" onclick="query()">
</form>
<body>
</html>

<script language="javascript">
function query()
{
var strShape;
var ret= window.open("b.html","query");
}
</script>

========================================
b.html:

<html>
<body>
<form name="form1">
<input type=text name="a" value="条件一">
<input type=text name="b" value="条件二">
<input type=text name="c" value="条件三">
<input type=button value="doquery" onclick="doquery()">
</form>
<body>
</html>

<script language="javascript">
form1.c.focus();

function doquery(){
window.opener.form1.a.value=form1.a.value;
window.opener.form1.b.value=form1.b.value;
window.opener.form1.c.value=form1.c.value;
//window.opener.form1.submit();
window.close();
}
</script>

big_fish 2006-03-10
  • 打赏
  • 举报
回复
关键是该,还容易改错,有的一个页面,查询条件就有20个,来回在在list和query中修改,麻烦是一回事,关键还是容易错!
isloop 2006-03-10
  • 打赏
  • 举报
回复
有3个月的时间楼主早用showModalDialog()改完了。不是我们遇到的问题都必须要解决,而是不必要的要解决,像楼主说的这样的是不推荐用别的方法解决的。程序员不能因为自己的工作量大而放弃程序本身的性能。
superman421 2006-03-10
  • 打赏
  • 举报
回复
这个没有办法了,改咯!
还是帮你顶下。
天地客人 2006-03-10
  • 打赏
  • 举报
回复
帮你UP了!

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧