javascript: how to access window.top from window.opener? - javascript

I am trying to refer to window.top in my popup window here http://www.globalrph.com/davescripts/popup.htm
once in the popup I want to access the main window's document but window.top is returning undefined.

To access your popup's opener use.
window.opener
To access your opener's top (e.g your opener is in an iframe)
window.opener.top
Once at the opener window you want you can access the document to change its context, the location to manipulate the URL etc.

If you want to move your popup to the same top position as the opening browser window and centered horizontally to the size of the opening browser window, in modern browsers you can use:
window.moveTo(window.opener.screenX + (window.opener.outerWidth / 2) - (window.outerWidth / 2), window.opener.screenY)
outerWidth and screenX and screenY work in IE9 and above and in modern browsers.
moveTo has been around a long time.
In this case we're getting the left position of the opening browser window, calculating its center and subtracting half the width of the popup. That gives the center position. Then we use window.opener.screenY to get the top position of the opening browser window and setting the popup's top the same.
Many browsers have popup blockers turned on by default and will require the user to click a link to open a popup. I have this web application that opens a popup window to preview the results. A lot of web applications use a positioned div for dialogs. Not knowing your application, I really can't give advice as to the best approach to take.

Related

How to detect if current window is behind another window, using Javascript

Is it possible to detect whether the web browser window is currently covered by another window?
document.hidden and document.visibilityState only changes state on switching tabs or when the entire window is minimized.
document.hasFocus() returns false if the window is visible but not in focus (e.g. the focus is on the taskbar)
Nope, that's not possible.
There's no way in JavaScript to know how visible the window is.
Browser windows overlapping one another, the position of the browser windows, and which one of them is on top - these functionalities are handled by the operating system.
No matter what code you write for your webpage, you cannot tell if your browser window is overlapped by another.
So yeah, the answer is NO.

How to force jqxWindow to be topmost

I use js jqxWindow on my web page. They are frames allowing to be moved, resized, and got focus.
But each time I select a jqxWindow, this becomes the topmost one.
I need to kept some other windows topmost. How to do that ?
I believe that the only solution for this is to apply bringToFront in the opening code of the other windows to the window, which shall always be on top.

JavaScript window options

I'm looking to create a "pop-up" window that simply displays text within the window without the browser's signature. When I create a window simply by using the window.open command, the Chrome symbol and address bar is displayed.
Is there a way to get rid of this?
Or is there a smarter way of doing this?
Also, with that being said, I want this window to stay on top of all other windows being displayed. That is, I want it to essentially be running on top of a window even though I may be clicking on a full screen window behind it.
No, this is intentionally made not possible (at least in Chrome) because it could be used to confuse the user to think that a browser window is a window for another program.
Google Chrome window.open height includes URL bar

How do I open a window on a different screen?

I have an IE7 app that needs to open a popup window onto a second screen. I'm fudging this at the moment by extending the desktop and explicitly opening the window at an offset that makes it appear over on the other one. However this seems like a hack and I'd like to be able to explicitly set the window screen when I call window.open(). Is there any way to do this?
I'm pretty sure this isn't possible. I did some testing and the pop-up windows seemed to be restricted to the monitor "with focus".
Demo: jsfiddle.net/Marcel/25W29

windows.open() method error

window.open() of javascript, it is working fine in other browsers, but in case of ie-8 it shows some error such as popup.
You're probably getting stopped by the pop-up blocker.
window.open ("http://www.location.com", "mywindow","status=1,toolbar=1");
The allowed parameters are as below
status The status bar at the bottom of the window.
toolbar The standard browser toolbar, with buttons such as Back and Forward.
location The Location entry field where you enter the URL.
menubar The menu bar of the window
directories The standard browser directory buttons, such as What’s New and What’s Cool
resizable Allow/Disallow the user to resize the window.
scrollbars Enable the scrollbars if the document is bigger than the window
height Specifies the height of the window in pixels. (example: height=’350′)
width Specifies the width of the window in pixels.
(Shamelessly copied from here)

Categories

Resources