JavaScript switching tabs & windows in same browser - javascript

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!

Related

Javascript Parent/ Child Id Control

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.

Is there any event which will be fired when I click on a tab in google chrome?

I am developing an extension for google chrome. I want to find the URL of the current tab, whenever I click on any tab in chrome. If I have three tabs open "abc.com","xyz.com","mnc.com" and when I click on first tab, I want an event to be fired, where I can get the current URL("abc.com"), and when clicked on the second tab,I should get the URL as "xyz.com". Is there any way to achieve this?
I am new to Chrome extensions and any help is appreciated. Thanks in advance.
There is no event that would indicate that a tab was clicked if it does not change the active tab. I mean, if you were on tab 1, and click it again, it will not emit any event.
There are, however, some events in the tabs/windows APIs that can approximate what you want when the active tab changes.
Specifically, chrome.tabs.onActivated will alert you when the active tab changes (this includes opening a new tab that is focused).
You might also want to use chrome.windows.onFocusChanged to track switching to a window without changing the active tab.

Is it possible to switch to previously opened tab instead of opening a new one?

In the website I am building I have a link to another webpage set with a target of _blank to open in a new tab.
If I click the link and then switch back to the 1st page and click the link again it opens a 3rd tab.
Is there any way to get the browser to just switch back to the already open tab for the 2nd webpage?
You can use target="secondPage", this create a named window/tab and every links that a user click that has this target will be opened in this page.
Other than this, I don't think it's possible nor a good thing. You should not tell the user how to manage his tabs/windows.

how we can restrict user to click or go on the browser window until they close the opened pop up window?

I am making a web application which takes the exam related programming languages, and i am opening a pop up window for test when a user click to start a test ,
but i want to restrict them to go on the main broweser window until they submit the exam(pope up window closed automatically) or they will close manualy
As far as i know its not possible with javascript. but cant you better use a box that will lay on top of the original page content like you can do with Jquery.
http://jqueryui.com/dialog/#modal-form
Removing the buttons and other forms of cancelation and only leave a post button when all answers are given.

ExtJS Managing windows and detecting front window

I have an application that has many windows, which can be handled by corresponding buttons on a toolbar (sounds familiar right?!)
I currently have it so that if you click a button on the toolbar, if it is not ontop bring it to the front (toFront), if it is minimised, maximise it etc.
I want to be able to detect whether the window is the front most window...
Cheers
EDIT
TO further describe the situation: say if I have a window that is at the front, or "active". Then I click the corresponding toolbar button which minimises that window. I want to then find which window becomes "active".
To manage your Ext.Window instances use the Ext.WindowMgr singleton:
http://dev.sencha.com/deploy/dev/docs/?class=Ext.WindowMgr
In a button's handler:
// Assuming 'winID' has been populated with the ID of an
// Ext.Window instance associated with the button.
win = Ext.WindowMgr.get(winID);
win.show();
Ext.WindowMgr.bringToFront(win);
win.maximize();
Why not set an activeWindow property as part of the handler for clicking a button on the toolbar? If the window associated with that button is already at the front, there's nothing left to do.

Categories

Resources