P
P
PO6OT2015-04-11 18:32:54
JavaScript
PO6OT, 2015-04-11 18:32:54

How to use js to know if a page is open in a new tab?

How to use js to know if a page is open in a new tab?
And, if it's not difficult for you to write a script, then how to assign the value style="display: none" to a block with id="back" if the page on which this block is opened in a new tab?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
PO6OT, 2015-04-11
@woonem

document.getElementById('back').style.display = (window.history.length == 1) ? "none" : "";

P
Philipp, 2015-04-11
@zoonman

javascript.ru/tutorial/dom/intro#style
To recognize "open in a new tab", the sessionStorage object is used .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question