0

I have multiple web pages that makes up 1 site. Each page includes a help button on the bottom of each page. This button directs the user to another site where a help page is offered.

the problem is that each button will open a new tab directed to the same help site. My goal is to only have 1 new tab opened for all for all of the button clicks on the separate pages.

I am currently using

function showHelp() {

var helpUrl = 'url'

mainHelp = window.open(helpUrl, 'help')     }




<a href="##" onClick="showHelp()"; return false">
Max G
  • 3
  • 2
  • I know there is a lot of information about my problem, however nothing I have tried has worked to this point. I am using ie11. – Max G Dec 23 '15 at 22:13
  • Is there a specific reason you are using JS to open this window instead of a traditional HTML anchor element? – hopkins-matt Dec 23 '15 at 22:17
  • Sounds like this issue: http://stackoverflow.com/questions/19098535/how-can-i-check-if-website-is-already-opened-in-a-webbrowser You would need to have your browser determine if the site is already opened in another tab... – Enkode Dec 23 '15 at 22:23
  • I have also tried just putting the window.open() in the tag and I get the same result. – Max G Dec 23 '15 at 22:34
  • In the example provided, I can see in the foreach loop that checks the browser for open tabs. Would I insert the window.open() in this as well if the condition returns true? or how would i implement this for my situation – Max G Dec 23 '15 at 22:37

1 Answers1

0

Your code is so closed to working, just a few typos and syntax error. Here's the similar code:

HTML:

<a href="#" onclick="showHelp('https://www.google.com/'); return false;">Open Google</a>
<a href="#" onclick="showHelp('https://www.yahoo.com/'); return false;">Open Yahoo</a>

JS:

var helpWindow;

function showHelp(url) {
    helpWindow = window.open(url, 'helpWindow');
}

You don't have to assign the result of window.open to helpWindow if you don't want do. Having the helpWindow assigned, you can close it later by running:

helpWindow.close();

NOTE: The code in this answer has been test with Chrome, Firefox and Safari on MAC OSX only.

Will
  • 1,718
  • 3
  • 15
  • 23