I want using JavaScript to see if there is history or not, I mean if the back button is available on the browser or not.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Short answer: You can’t.
Technically there is an accurate way, which would be checking the property:
However, it won’t work. The problem with this is that in most browsers this is considered a security violation and usually just returns undefined.
Is a property that others have suggested…
However, the length doesn’t work completely because it doesn’t indicate where in the history you are. Additionally, it doesn’t always start at the same number. A browser not set to have a landing page, for example, starts at 0 while another browser that uses a landing page will start at 1.
Most of the time a link is added that calls:
or
and it’s just expected that if you can’t go back then clicking the link does nothing.