What's different when a page is opened by window.showModalDialog? - javascript

Anyone knows the difference?
The problem I met is that the page stops working correctly when opened by window.showModalDialog

window.showModalDialog vs window.open
Window.open will open up a new window through Javascript, with the URL and other features of the window that u pass as parameters. Here the parent window which opens the new window and the child window are independent windows.
Eg. Below
`window.open('winOpen.htm','name','height=255,width=250,toolbar=no,directories=no,status=no,
linemenubar=no,scrollbars=no,resizable=no');`
Window.showModalDialogue again works smilar to a window.open only diffrence being its a Modal window, It opens up as a new window but doesnt allow the user to access the parent window, unless you explicitly close it.
Here the child window is dependent on the parent window. If you close the parent window the child would also get closed.
window.showModalDialog("xpopupex.htm","name","dialogWidth:255px;dialogHeight:250px");
ShowModalDialogue windows can be used when u want the user to perform a particular action in the new window before he access the parent window again. like login before he can access the parent page..
tryed to make it as simple as possible...hope this help.. ;)

Related

How to create a pop up browser window that contains a GUI and controls a parent browser window

Is there a way in jquery and/or javascript to create a pop up window that can directly effect a parent window in a browser? In my case I want to set up a GUI in the pop up which can move objects in the parent window left/right/up/down. I also need this to work in a dual monitor setting. Any leads on how to do this would be great!
Functions in the child window can control the parent window by using parent. for example:
parent.alert("moo");
You can use window.opener to interact with the opening window, since it sounds like you want to open a new window. So if you have a javascript function declared in the opening window as
function test(){
alert("I'm the parent!");
}
you can call it from a popup window by calling
window.opener.test();
The requirement here is that both the opening window and the open window must be either in the same domain or at least subdomain. If it is the same subdomain, a little work is needed to allow the cross-domain access, which you can read more about here https://stackoverflow.com/a/3962489/1558122.
You would initially open the popup of course by calling window.open from the parent, and dual monitor should not affect the behavior here.
What you really want is probably a dialog, not a window. Windows are cumbersome and require all the HTML a document requires. You could try this jquery plugin: http://jqueryui.com/dialog/ . A dialog requires minimal HTML.
I confess I don't know about the dual-monitor thing.

How to open current page in new window

What i want to do is when the user opens their browser and types http://xyz.com/index.html, then it should pop up a new full screen window and then display index page in that new window.
I tried with using window.open('login.html', 'new_windwo', '_self'); and it opens a new window, but then there are 2 windows — one where user typed the URL, and the 2nd that we have open in the onLoad of the first page.
I am not able to close the first window — self.close() and window.close aren’t working. I am using Firefox 3.6.
Is there is any way that I can open current page in new window, without creating duplicate?
Thanks.
No. You can't destroy a window that you didn't create with a script in the first place.

Window to Window Communication in js by window name

Is there anyone who can give me some thoughts on how to handle window to window communication using javascript givin that the two windows has no parent child relationship. Basically the other window is opened using window.open method. Any brilliant information is well appreciated.
assuming the following:
windowHandle=window.open('path/to/document');
you can interact between both windows.
You have a pointer to the window-object from the document where it was opened from using the variable-name:
//doSomething has to be known inside the new window
windowHandle.doSomething();
and from the document inside the new window to the window that opened the new window, using the opener-property:
//doSomething has to be known inside the window that opened the new window
opener.doSomething();

About Popup window data to Parent window

I am opening one Popup window on Button Click in main window, it is for Image Uploading.
when I am uploading Image , i.e. on Upload button click I am closing this Popup window and opening new Popup window.
And Now I want to display the Popup data to Parent window without refreshing, But I am not getting Parent window object.
i.e. window.opener or window.parent. Please give me help. How I will get Parent window object?
you can try this,
When first popup window is opened(uploading image window) get parent window object for this popup and store in some variable(java script variable ) like this
var parentWindowObject=window.opener;
Try passing this object variable to the second pop up window( on upload click) and in this page you will get it main page window reference (parentWindowObject) and using this you can fire new request to main page to post your required data as follows
parentWindowObject.location="your request";
Reason for not using window.opener in second popup
As you are opening a new popup from the present popup. The parent for the newpopup will be the popup which you are opening from here is your upload popup and you are closing the upload popup once you click on upload so for the new popup the value for window.opener(a reference for the parent window) will be null.
You can access the parent window by using window.opener
See window.opener
which returns a reference to the window that opened this current window. When a window is opened from another window, it maintains a reference to that first window as window.opener. If the current window has no opener, this method returns NULL.

From pop window active the parent window

Using JavaScript I open the pop window and parent window is inactive at this time,
I wanted to active parentwindow through popwindow. (this is a web project on Java)
You can usually window.opener in JavaScript to get at the window that opened at popup.

Categories