Switching between the same two tabs only in browser using javascript and html

My idea of ​​what I'm trying to do is When I open a website on one tab of the Internet browser browser and click on the link, it should open a new tab in the same browser using the pdf page ... on the pdf page there is there are many links that, if you try to click any of them, they should return you to the old tab, where you managed to dine, to open the PDF file and continue switching between these two tabs. I hope the idea is clear. I am trying to do this with html and javascript ... this is what I wrote, but I'm still missing here. Thank you in advance for your help.

this part here promises another moment in another window

<html>
<head>
<script>
function son()
{

 myWindow=window.open('','','width=500,height=500');
 myWindow.document.write(" SON !");
 myWindow.focus();
 myWindow.opener.document.write("<p> DAD !</p>");
}
</script>
</head>
<body>

<input type="button" value="Open " onclick="son()" />

</body>
</html>

There is a pdf file in this file.

<object data="Test.pdf" type="application/pdf" width="100%" height="100%">

<p>It appears you don't have a PDF plugin for this browser.
you can <a href="Test.pdf">click here to
download the PDF file.</a></p>

</object>

+5
3

window focus, / . ( ) , .

PDF, , . :

var pop = window.open('page.html'); // opens in new tab on most browsers

:

window.opener.focus(); // no longer works in most modern browsers

, :

pop.focus();  // might work

, IE 9 Chrome 21 openener. Chrome , , pop.focus() . (IE .) Chrome , window.opener.alert('...'); , .

, , , , .

, (TOC?), ? , , PDF.

+5

JavaScript API- . .

, , .

+1

One alternative option includes NOT opening a second window or tab. If you open another / replace the page in the current window or tab, you can use the History object to switch between the two pages.

history.go(-1); //takes you back to previous page
history.go(1);  //takes you forward to the page from which you went back.
+1
source

All Articles