我为你创建了一个例子,我希望这就是你要找的东西: 在这个例子中,我有两个页面,ParentTest1。 aspx和ParentTest2.aspx,以及将在弹出窗口中打开的页面是MyPopup.aspx, 好​​的我有一个Button和JavaScript来打开ParentTest1中的弹出窗口。 aspx: ParentTest1.aspx: < asp:按钮 runat = server id = BtnPopUp text = 打开弹出窗口 onclientclick = 返回OpenPopup(); xmlns:asp = #unknown / > function OpenPopup(){ var returnValue = window .showModalDialog( MyPopup.aspx?Qty = 1& ThumbnailUrl = http://honnex1-pc/JesusChristImg/pdfTojpg/LivingWater_LF1110201321117902.jpg& ItemNumber = D20131011153145960&操作=创建, , 高度:500,宽度:500;); 窗口。 lo阳离子 = returnValue.MyURL; return false ; } 我有一个提交按钮和JavaScript函数,可以在MyPopup.aspx页面上返回打开ParentTest2.aspx的URL。 MyPopup.aspx: < asp:button runat = server id = BtnSubmit text = 提交 onclientclick = 返回OK(); xmlns:asp = #unknown / > function OK(){ var vReturnValue = new Object(); vReturnValue.MyURL = ParentTest2.aspx?ID = AnyValue; window .returnValue = vReturnValue; window .close(); return false ; } 尝试一下,如果有帮助请告诉我。 Azee ... hi azee, i只需设计实际上我的代码正在使用window.open()但我有一个要求只有带有禁用父页面的window.open(),我的要求几乎就像jafar所说的那样.. 谢谢你Azee和Jafar。 Jafar如果可能的话请告诉我我必须做什么(禁用父窗口,打开子窗口,处理子窗口的焦点).. 谢谢 Neimish varaprasad.Suggala hi,i have an aspx page and when i click on button i need to open another url's page in window.open whick looks like a popup( what exactly my requirement is when i click on button the parent page should not be enable). And when i click on submit button on my popup window i need to send url and image to the another url which is a part of parent website page.process should look like here:parentpage1.aspx(www.xyz.com/parentpage1.aspx) -------> popup window page(www.123.com/child.aspx) ----->parentpage2.aspx(www.xyz.com/parentpage2.aspx)Popup window page is need toopen in window.open and background should disableactually i am trying with lightbox also but it's not working.And i tried with model popup also but i am unable to send data from popup to page(the data is url only )var navUrl = '<%=Session["ReturnUrl"] %>' + "?Qty=" + qty + '&ThumbnailUrl=' + '<%=ViewState["Thumbnail"]%>' + "&ItemNumber=" + '<%=ViewState["Document"]%>' + "&Action=" + '<%=ViewState["Action"]%>'; window.opener.location.href = navUrl;here the importent thing is the URL i am sending is like this below:<br />http://localhost:56595/Success.aspx?Qty=1&amp;ThumbnailUrl=http://honnex1-pc/JesusChristImg/pdfTojpg/LivingWater_LF1110201321117902.jpg&amp;ItemNumber=D20131011153145960&amp;Action=CreateThanks in advance,Regards,Neimish Varaprasad.Suggala 解决方案 Hi,var navUrl = '<%=Session["ReturnUrl"] %>' + "?Qty=" + qty + '&ThumbnailUrl=' + '<%=ViewState["Thumbnail"]%>' + "&ItemNumber=" + '<%=ViewState["Document"]%>' + "&Action=" + '<%=ViewState["Action"]%>';window.opener.location.href = navUrl;The above code will not set the values of querystring parameters until you make a postback.Now, you are specifying the href of the parent page. After the postback you will have to refresh the parent page. I think it is a wrong approach.Coming to your requirement:Your requirement is to disable the parent page as long as the child page is kept opened. Basically these popups are known as modal popups. Opening a window using window.open() method do not disable the parent page by default. You will have to handle a lot of things in that case. Disabling parent window, opening child window, handling the focus on the child window so that the user never lose the focus and stay on the page etc. A simple solution would be to use JQuery plugin that loads the external contents into the modal div. After that you can manipulate the DOM elements from the same page. You can use one of these:Magnific Popup[^]bPopup[^]I hope it helps.Hey there,I have created an example for you, I hope this is what you were looking for:In this example, I have two Pages, ParentTest1.aspx and ParentTest2.aspx, and the page that will open in popup is MyPopup.aspx,Ok I have a Button and the JavaScript to open the popup in ParentTest1.aspx:ParentTest1.aspx:<asp:button runat="server" id="BtnPopUp" text="Open Popup" onclientclick="return OpenPopup(); " xmlns:asp="#unknown" />function OpenPopup() { var returnValue = window.showModalDialog("MyPopup.aspx?Qty=1&ThumbnailUrl=http://honnex1-pc/JesusChristImg/pdfTojpg/LivingWater_LF1110201321117902.jpg&ItemNumber=D20131011153145960&Action=Create", "", "Height:500, width:500;"); window.location = returnValue.MyURL; return false; }I have a button to submit and JavaScript function to return a URL to open ParentTest2.aspx on MyPopup.aspx page.MyPopup.aspx:<asp:button runat="server" id="BtnSubmit" text="Submit" onclientclick="return OK();" xmlns:asp="#unknown" />function OK() { var vReturnValue = new Object(); vReturnValue.MyURL = "ParentTest2.aspx?ID=AnyValue"; window.returnValue = vReturnValue; window.close(); return false; }Try it and let me know if it helps.Azee...hi azee,i need just design only actually my code is working with window.open() but i have a requirement only window.open() with disabling parent page, my requirement is almost like what jafar has said..Thank u Azee and Jafar. Jafar if possible can you please tell me what i have to do for this ( Disabling parent window, opening child window, handling the focus on the child window)..ThanksNeimish varaprasad.Suggala 这篇关于使用window.open()打开一个页面,如模型弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 12:55
查看更多