Can the name of a window opened using window.open be changed dynamically by the main parent?
We have a menu system that opens new windows when a link is clicked. The new window then has other windows that can be opened from it. This method works fine in a one session environment. But when users try to open a second window from the same option the first window is replaced. I know this is due to them both using the same name. Can the main menu program be coded to change the name each time a menu item is clicked? Can this same menu program change the name of the children windows from the first window?
The best method I can think of is finding a way for a javascript listener to be opened and triggers each time a link is clicked, within each separate parent/child tree. I however don't even know if this is possible.
I know I have the option to append a unique number to each window.open command name, but I am looking for a way to allow the menu program to handle this.
I am looking for a method that won't require changing the child programs.
Thank you.
Related
First of all I need to determine which window or tab is actually opened in browser at the moment. I need it's name or create it by specifying unique value which I'm able to find for each one of them.
Then I need to switch between these tabs and windows. Are there any commands to do so?
I Need to copy some string value.
Need to change tab.
Click a button.
New window appears.
Click a button.
Paste this text.
Click a button.
Close this window.
Get back to 1st tab I was on.
Those are steps I want to automate.
Thank you in advance for any help!
I'm having an issue with a our main application's window activating itself when the mouse is hovered over it.
I'm opening the new window in a javascript function using the line below:
window.open(URL, 'Requests', 'location=no,toolbar=no,status=yes,scrollbars=yes,resizable=yes');
I have noticed that if I open a new IE window through Explorer, hovering over our main application's window does not reactivate itself. Even in this case though, the main window does make itself be "on top" of the pop-up window created by the window.open command above.
The question is this: Is there any way, when opening a "child" window in javascript, to detach the child window from the parent?
Further info: I am using an Infragistics WebDataMenu with ActivateOnHover set to true so users don't need to click on main menu items to see sub-menu choices. Unfortunately, that setting sensitizes the whole menu bar so that sliding the mouse through it activates the menu (and sadly the window when a popup is active). This is the root behavior I'm trying to fix.
The window.open(); method will create a popup window that really only shares a relationship through JavaScript via the return value of the call, and the window.opener property on the popup window.
What you want is the behavior of a modal window that locks out interaction from the 'parent' page while you work on the 'child' popup.
You can try to fight with JavaScript (and your users) by forcing a focus on the popup and blocking any blurring but this will drive users nuts when they want to go read their email etc. (eg not recommended)
You can also use the not so standard showModalDialog(); method but support is far from fully cross browser and there are a whole bunch of new problems if you try to use this (no right click in IE, zoom issues in IE, and no grandchildren popups to name a few) (again not recommended)
What you can do is make an "overlay" popup similar to many online photo viewers where you first overlay a mask (typically semi transparent) that blocks mouse/focus on the entire page content below and then overlay that with your "popup content". Just be sure that you provide a close option that removes the mask when the overlay is closed/done.
Note if you need to support IE6 you'll also need an iframe shim (Google if needed)
Many UI frameworks will provide a "dialog" just like this for you. (Eg jQueryUI)
Ultimately, I gave up on making this work. I found that what I had to do was turn off ActivateOnHover from the WebDataMenu, which didn't answer this question and requires users to click on the menu to make it drop down, but it became a work-around.
I should preface this with the fact that I know virtually nothing about javascript and, apart from very rare situations like this, I don't really plan on using it much. So please forgive me for not having tried to learn more about it in order to try and solve this problem for myself.
The Situation:
I frequently like to make use of popout browser windows. To do this I created a bookmark in my browser that contains this small piece of Javascript I copied from somewhere – I can't remember where – and adapted to suit my screen:
javascript:%20var%20WindowPopup%20=%20window.open(window.location.href,'PopUp','left=1150,top=830,width=660,height=410,scrollbars=yes,location=no,status=no');
The Problem:
As things stand, when there is an existing popout window and I select the bookmark again, the same popout window is re-used if I'm at the same site, otherwise a new popout window is created. But there are many occasions when I would like to override this default behaviour.
Three Qustions:
How can I force popouts to always open in a new window?
How can I force popouts to always re-use an existing window?
Combining the previous two options: is it possible to detect if there is an existing popout window and prompt me as to whether I want to re-use it or open a new one?
Your help will be greatly appreciated.
The String "PopUp" in your bookmarklet is the name of your popup window. If you create another popup window using the same name, the already opened window will be reused.
If you want to get around this behavior, you will have to create a popup window with a unique name every time.
The following bookmarklet code will append a timestamp to the name of the popup window creating a unique name:
javascript:%20var%20WindowPopup%20=%20window.open(window.location.href,'PopUp'+Date.now(),'left=1150,top=830,width=660,height=410,scrollbars=yes,location=no,status=no');
This should work unless you're opening multiple popups within a millisecond.
I have this link in my left navigation:
dashboard
That javascript opens a link based on the passed parameters.
All works fine, but I would like to be able to use the browser capabilities of opening the links in a tab (when user is using middle click or selects 'Open link in new tag' from right click menu). Though, this is not working for links handled with javascript code.
There are many reasons why this is not the default behaviour of the browser (e.g. javascript function might only do some validation and stay in the page ... browser can't know what the js might do or if a new window/dialog will result from that action so would make no sense to open new tag as a result of a middle click ...). But hopefully there is a workaround for the default behaviour.
Any idea how this could be done?
Cheers,
Stef.
Javascript links execute in context of the page where they are called. If you "open" the link in a new tab/window, the javascript code will be executed in the new window, i.e., empty, and will most probably fail.
A browser could try to add the feature you are asking for by cloning the page which contains the link, and executing the javascript code in the context of the cloned page. But this would most likely break some critical sites (imagine for example that your online banking site works with javascript, so when you open a link in a new tab/window, cloning the original window might lead to a duplicate transaction).
How to open 2 different link one in same window and another one in new window from one link? I want to open one link in parent window and other one in new window not new tab in all A-Grade browsers
Use a javascript function that first calls window.open and then window.location.
Typically, if you use window.open and specify a height and width for the window it will cause most browsers with most configurations to open it as a new window and not a new tab.
The following will add a popup window to the link with the id link-of-doom. Specify the link that you want the current page to redirect to in the href attribute as you normally do.
HTML
Click me!
JavaScript
$(function() {
$("#link-of-doom").click(function() {
window.open('/page2.html', 'sometarget', 'width=400,height=200');
});
});
* You should not use the onclick attribute in the HTML itself as it is not considered a best practice . . . and a kitten is killed every time someone uses it.
Your link
This may or may not work, depending on whether the 'onclick' handler runs before the standard behaviour of the link.
If it doesn't - or is intermittent - let me know, and I'll supply an alternative approach.
EDIT:
As an alternative, I'm thinking that you could have 2 links, one for the 'new' window and one for the 'current' window. Make the 'current' window link invisible, using css, amd add an 'onclick' handler to the 'new' link, that fires the 'current' link.
Your link
Hidden link
Be sure to check this on multiple browsers.
P.S. I'm assuming that you're using jquery - if not, the code that triggers the 'click' event will need to change.