1

One function in my website requires that the website be opened in a new window rather than a new tab.

Is there any way to determine if the page is opened in a new window or a new tab and show an informative message to user?

-----Edited and added below to distinguish from an already asked and answered question.-------------

I do not want to open my page in a new window if it has already been opened in a new window.

I want to determine if the page is opened in a new window and if not, to provide an informative message to the user and give the option to open my website in a new window, if the user so chooses.

One of the functions on my website involves resizing the window to half its original size. Resizing is not possible inside a tab and hence this question.

The workflow is:

1) Open my website.

2) Determine if it is in a new window.

3) If yes, then continue.

4) If no, then advise visitor about the need to open in a new window and provide button, "Open in a new window?".

5) If clicked, Open the website in a new window (with a unique window name) and change focus to the new window.

6) If not clicked - continue as a tab.

Some functions which require resizing, will not work properly as a tab, though.

--------End of edit------------

  • seems, not, separated window or tab - same on js side – Grundy Nov 22 '15 at 17:25
  • I don't think this is possible - as far as the web page is concerned, a tab is the same thing as a window. – edcs Nov 22 '15 at 17:26
  • [A similar question was asked and has been answered here.](http://stackoverflow.com/a/1834579/4434385) – Jonathan Griffin Nov 22 '15 at 17:27
  • Possible duplicate of [Target='\_blank' to show in new window, NOT new tab, possible?](http://stackoverflow.com/questions/1834559/target-blank-to-show-in-new-window-not-new-tab-possible) – Grundy Nov 22 '15 at 17:31

1 Answers1

2

You can check the history.lenght to know that if a new page/tab is opened or not. but totally knowing the difference between window is tab is a bit complex. you may check the menubar.visible too, to get hint for your problem.

Overally please check the following link for further comments and ideas: How do identify whether the window opened is a pop up or a tab

Community
  • 1
  • 1
Vahid Farahmandian
  • 6,081
  • 7
  • 42
  • 62
  • Thank you Vahid for both the edits on my original question and your response. While checking for toolbar being visible (as suggested in the link you provided), may be one way, it may not work in every case as the original window in whose tab my website would be opened, may have been done with toolbar being NOT visible. The solution seems to be in the direction of checking existence of a tab bar and how many tabs are opened - but I have found no Javascript function to check that. Thank you again! – Uttam Padukone Nov 22 '15 at 18:42