页面弹出子页面(完整的页面) 在子页面编写内容并jsp前台提交不完整,父页面跟着改变怎么实现的,

window.open 打开子页面,怎么在子页面操作父页面的方法或者直接更改父页面的元素?
chrome浏览器用window.open 打开子页面,怎么在子页面操作父页面的方法或者直接更改父页面的元素
我做过类似的,将父页面你要修改的元素操作包装成方法并放进一个对象,然后创建子页面给父页面产生子页面window的引用,将这个对象复制到这个window的指定变量上,子页面之后可以读取这个对象获得操作方法。
已有帐号?
无法登录?
社交帐号登录屌丝码农们接单利器的首选解决方案-基本权限管理系统2012——
世间自有公道,付出总有回报,说到不如做到,要做就做好,步步高!
jQuery.Easy-UI QQ讨论群:(超级)、 (Full)、271061
近期 在群中有一个网友总是在纠结这个问题,很多朋友也给出了解决方法,可能不是很深入而该网友的经验可能还差那么一点点。所以我决定为了摆脱其无休止的&纠缠&,就写了小例子给他,现在跟大家分享下,有遇到这种情况的朋友可以参考下,下面是具体实现过程
首先在首页也就是父页面中加一个空DIV容器。如:&div id="pwin"&&/div&
子页面中的内容如下:
&input type='button' id="btna" value="在父级弹出窗口" &
&div id="d" style="display:"&
&input type="text" name=""&&br&
&input type="text" name=""&
&input type="submit" value="提交"&
var $parent = self.parent.$;
$(function(){
$('#btna').click(function(){
$parent('#pwin').window({
modal:true,
width:300,
height:200,
content:$('#d').html(),
title:'父级窗口'
到这里就结束了,简单吧,其实大家在做时候会发现,如果页面中要操作的表单很多,这样页面中就会出现很隐藏的DIV,页面看起来很零乱,所以大家可以表单中的HTML放单独的HTML文件中,利用window的href属性加载表单,这样一来,页面就清晰很多了,大至代码会像下面这样:
var $parent = self.parent.$;
$(function(){
$('#btna').click(function(){
$parent('#pwin').window({
modal:true,
width:300,
height:200,
href:'xxxx.html',
title:'父级窗口',
onLoad:function(){
//在此加入表单初始化的相关代码。
在使用的过程中遇到问题,欢迎大家到群中讨论。有不当之处还望指出。
转载请注明出处
撰写人:疯狂秀才
阅读(...) 评论()利用js怎么实现父窗口关闭了从父窗口打开的多个子窗口也跟着关闭呢
利用js怎么实现父窗口关闭了从父窗口打开的多个子窗口也跟着关闭呢.不一定要用js,其它方法也可以,只要能达到效果就可以了。。拜托了大家帮帮忙!谢谢了~
09-12-15 &匿名提问
您好IE关闭后APPLICATION值不会马上消除,你可以将APPLICATION值设为空以达到消除值的效果
请登录后再发表评论!当前位置:&&
本页文章导读:
&&&&?jquery 子窗口操作父窗口的代码&&&&&&
$("#父窗口元素ID",window.parent.document)...就行了 js 版本 view sourceprint?1.window.parent.document.getElementById()
......&&&&?通过JS 获取Mouse Position(鼠标坐标)的代码&&&&&&
昨天写的脚本在获取鼠标位置的时候有些问题。在IE中始终当有滚动条的时候,发现document.body.scrollTop并没有起到作用。后来在google中搜索到一篇文章Mouse Cursor Position,详细介绍了浏览器鼠标......&&&&?IE,firefox(火狐)浏览器无提示关闭窗口js实现代码小结&&&&&&
经编辑整合的版本:注意 如果你使用的是firefox浏览器必须要做以下设置 1、在地址栏输入about:config然后回车,警告确认 2、在过滤器中输入”dom.allow_scripts_to_close_windows“,双击即可将此值......
&&&&&&最新IT科技资讯推荐:
[1]jquery 子窗口操作父窗口的代码
&&&&来源:&互联网& 发布时间:&
$("#父窗口元素ID",window.parent.document)...就行了 js 版本 view sourceprint?1.window.parent.document.getElementById()
[2]通过JS 获取Mouse Position(鼠标坐标)的代码
&&&&来源:&互联网& 发布时间:&
昨天写的脚本在获取鼠标位置的时候有些问题。在IE中始终当有滚动条的时候,发现document.body.scrollTop并没有起到作用。后来在google中搜索到一篇文章Mouse Cursor Position,详细介绍了浏览器鼠标定位的问题。各个浏览器对鼠标定位的标准不一样,就连不通版本的ie对定位支持都不一样。document.body.scrollLeft,document.body.scrollTop只用于IE6以前的版本,在IE6中,对没有宣告 DOCTYPE,或者宣告的是transitional DOCTYPE,那么IE6将使用document.documentElement.scrollLeft 来获取鼠标的绝对位置。
将Stephen Chapman提供的函数做个记录
function mouseX(evt) {if (evt.pageX) return evt.pageX;else if (evt.clientX)
return evt.clientX + (document.documentElement.scrollLeft ?
document.documentElement.scrollLeft :
document.body.scrollLeft);}function mouseY(evt) {if (evt.pageY) return evt.pageY;else if (evt.clientY)
return evt.clientY + (document.documentElement.scrollTop ?
document.documentElement.scrollTop :
document.body.scrollTop);}Mouse Cursor Position Join the Discussion Questions? Comments? Until recently there was no standard way of determining the position of the mouse cursor within the browser. The W3C standards say that the current mouse cursor position within the browser window when an event is triggered should be given by event.clientX and event.clientY to obtain the distance from the left and top of the browser window respectively. I have tested this in a number of different browsers and have found that Internet Explorer 6, Netscape 6+, Firefox, and Opera 7+ all produce correct values for the mouse coordinates relative to the browser window in these fields. To obtain the position within the web page you would simply add the scroll position of the page within the browser window. Opera 5 and 6 produced values for these fields but the values are relative to the top of the web page instead of relative to the browser window and so adding the scroll position would produce a wrong result with these browsers. Netscape 4 doesn't understand these fields at all and so would give an error if this code were used by itself. One added complication is that Internet Explorer uses two different ways to determine the scroll position of the page. It uses document.body.scrollLeft and document.body.scrollTop in versions before version 6 as well as in version 6 when there is no DOCTYPE declared or a transitional DOCTYPE is declared. When IE6 is declared using a strict DOCTYPE document.documentElement.scrollLeft and document.documentElenent.scrollTop are used instead. Other browsers either use one of these values or pageXOffset and pageYOffset. Although not part of the W3C standards there is another pair of fields that will give the position of the mouse cursor that is useful. With the exception of Internet Explorer and Opera 5 and 6, all of the browsers I have mentioned also support event.pageX and event.pageY which give the mouse cursor position relative to the top left corner of the web page itself. Using these fields you do not have to add the scroll position of the page. By combining tests for both of these methods together we can create code to locate the mouse cursor position that will work on Internet Explorer, Netscape 4+, Firefox, and Opera 7+. You just need to pass the event to the following functions to retrieve the appropriate position on the web page. function mouseX(evt) { if (evt.pageX) return evt.pageX; else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
} function mouseY(evt) { if (evt.pageY) return evt.pageY; else if (evt.clientY) return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
} There are a couple of other pairs of fields that give mouse cursor positions that are less useful. The fields event.screenX and event.screenY are defined in all of the browsers I tested. They give the position of the mouse cursor relative to the top left corner of the screen. Without knowing the position of the top left corner of the browser window this information is not very useful with respect to being able to interact with the web page. The fields event.x and event.y also exist in Netscape 4, Internet Explorer, and Opera 7+. In Netscape 4 these fields give the position within the web page exactly the same as the pageX and pageY fields. In Internet Explorer and Opera 8 they give the position of the mouse cursor within the current object (if that object is positioned absolute, relative, or fixed) or within the page (for static objects). Opera 7 appears to use these fields to give the position of the mouse cursor relative to the bottom left corner of the screen. 还要其他的情况: 调用方法:
代码如下: var pos=GetObjPos(ID); function CPos(x, y) { this.x = this.y = } //获取控件的位置 function GetObjPos(ATarget) { var target = AT var pos = new CPos(target.offsetLeft, target.offsetTop); var target = target.offsetP while (target) { pos.x += target.offsetL pos.y += target.offsetT target = target.offsetParent }
下面是我自己开发项目中的实例:
代码如下: &script type="text/jscript" language="jscript" & function showPopup(obj,evt) { var strDate = $(obj).attr('dateTime'); var strUserName = $(obj).attr('userName'); var id = "event_" + strDate.replace(/-/g, ''); var box = $('#'+id); if (box.length == 0) { $(document.body).append("&div id='" + id + "' &&/div&"); box = $('#' + id); box.css("position", "absolute"); box.css("display", "block"); box.css("z-index", "100"); box.append('&input id="File1" type="image" src="../Images/Onload.gif"/&'); Microsoft.PMWeb.WebSite.SiteService.GetEventInfoByDate(strUserName + "#" + strDate, onSuccess, onFailed, "1111"); } else { var imgLoad = box.find(":image"); imgLoad.css("display", "none"); } var objQueryPosition = GetObjPos(obj); box.css("left", mousePos.x); box.css("top", mousePos.y); box.css("display", ""); function onSuccess(result, context, methodName) { var imgLoad = box.find(":image"); imgLoad.css("display","none"); box.append(result); } function onFailed(error, context, methodName) { var errorMessage = error.get_message(); alert("Review Failed:" + errorMessage); } } function hidePopup(obj) { var strDate = $(obj).attr('dateTime'); var strUserName = $(obj).attr('userName'); var id = "event_" + strDate.replace(/-/g, ''); var box = $('#'+id); if (box.length != 0) { $('#'+id).css("display", "none"); } } var mouseP function mouseMove(ev) { ev = ev || window. mousePos = mouseCoords(ev); } function mouseCoords(ev) { if (ev.pageX || ev.pageY) { return { x: ev.pageX, y: ev.pageY }; } return { x: ev.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft), y: ev.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) }; } document.onmousemove = mouseM &/script&
[3]IE,firefox(火狐)浏览器无提示关闭窗口js实现代码小结
&&&&来源:&互联网& 发布时间:&
经编辑整合的版本:注意 如果你使用的是firefox浏览器必须要做以下设置 1、在地址栏输入about:config然后回车,警告确认 2、在过滤器中输入”dom.allow_scripts_to_close_windows“,双击即可将此值设为true 即可完成了。 js关闭窗口兼容firefox、chrome、ie
代码如下: function windowclose() { var browserName = navigator.appN if (browserName=="Netscape") { window.open('', '_self', ''); window.close(); } else { if (browserName == "Microsoft Internet Explorer"){ window.opener = "whocares"; window.opener = window.open('', '_top'); window.close(); } } }
在IE7/ Firefox 3.0/ Google Chrome通过测试 CloseDemo.htm 代码如下:
代码如下: &script& var browserName=navigator.appN if (browserName=="Netscape") { function closeme() { window.open('','_parent',''); window.close(); } } else { if (browserName=="Microsoft Internet Explorer") { function closynoshowsme() { window.opener = "whocares"; window.close(); } } } &/script& &input type="button" value="close me 3" onclick="closeme();"/&
测试比较好用代码:
代码如下: &script type="text/javascript"& function closeme() { var browserName = navigator.appN if (browserName=="Netscape") { window.open('','_parent',''); window.close(); } else if (browserName == "Microsoft Internet Explorer") { window.opener = "whocares"; window.close(); } } &/script& &input type="button" value="close me 3" onclick="closeme();"/& 以下内容仅供参考: 代码如下:&script type="text/javascript"& function closeme(){ var browserName=navigator.appN if (browserName=="Netscape") { window.open('','_parent',''); window.close(); } else if (browserName=="Microsoft Internet Explorer") { window.opener = "whocares"; window.close(); } }setInterval('closeme()',3000);&/script& 上面的setInterval('closeme()',3000);是为了延迟3秒关闭,如果不想延迟可以直接替换为closeme();即可。JavaScript无提示关闭窗口(兼容IE/Firefox/Chrome) 第一个下面是实际代码,比较不错,推荐使用。但ie兼容性不好
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]第二个:只针对ie7 ie8 ie6的代码javascript 无提示关闭窗口脚本
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]注意“ 如果你使用的是firefox浏览器必须要做以下设置 1、在地址栏输入about:config然后回车,警告确认 2、在过滤器中输入”dom.allow_scripts_to_close_windows“,双击即可将此值设为true 即可完成了 另下面是一些以前发的一些文章,但现在已经不能用了,但部分的东西,还是值得想深入的朋友参考的。试试下面代码: &object id="WebBrowser" width=0 height=0 classid="CLSID:A-11D0-A96B-00C04FD705A2"&&/object& &input type="button" name="Button" value="关闭窗口" onClick="document.all.WebBrowser.ExecWB(45,1)"& 试着改变参数会得到其他一些功能: WebBrowser.ExecWB(1,1) 打开 WebBrowser.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口 WebBrowser.ExecWB(4,1) 保存网页 WebBrowser.ExecWB(6,1) 打印 WebBrowser.ExecWB(7,1) 打印预览 WebBrowser.ExecWB(8,1) 打印页面设置 WebBrowser.ExecWB(10,1) 查看页面属性 WebBrowser.ExecWB(15,1) 好像是撤销,有待确认 WebBrowser.ExecWB(17,1) 全选 WebBrowser.ExecWB(22,1) 刷新 WebBrowser.ExecWB(45,1) 关闭窗体无提示 这些只对IE5.5以上版本有效,我是在IE6下测试的,通过的。 在不是js打开的页面上按window.close(),会有提示框,很烦,现在可以不用了,没有提示框直接关闭窗口。 以前有人贴过利用IE5.5/6.0漏洞做的无提示窗口, &object id="WebBrowser" width=0 height=0 classid="CLSID:A-11D0-A96B-00C04FD705A2"&&/object& &input type="button" name="Button" value="关闭窗口" onClick="document.all.WebBrowser.ExecWB(45,1)"& 但后来ie6.0出了补丁,便失效了 现在有一种很简单的无提示关闭窗口代码如下 : &input type="button" onClick="window.opener='dxy';window.close();" value="IE6最简单的无提示关闭窗口" &
最新技术文章:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!
(C)2012-,站长邮箱:www_169it_(请将#改为@)

我要回帖

更多关于 jsp前台提交不完整 的文章

 

随机推荐