EDIT-2: None of the answers seem to work. Not even the one I previously marked as the answer of this question. Any help is appreciated. Thanks.
check window.history.length or simply, history.length
history.length
EDIT: some browsers start their history with 0, others with 1. adjust accordingly.
if it has a value of 1, it means it's the first page in that window/tab - then you can have JS redirect you.
Back