Onclick javascript to make browser go back to previous page?
Add this in your input element
<input
action="action"
onclick="window.history.go(-1); return false;"
type="submit"
value="Cancel"
/>
Make browser back button show login page without error div
The thing is that when you press back the browser doesn't always reload the page, that's the reason of the logging still showing the error, so what you need is to force the page to reload. Here you have a link to the solution that im giving you, hope it works How to force reloading a page when using browser back button?
Edit:
Answering to your comment, yes, it should be placed in the js file, something like this should do the trick
var perfEntries = performance.getEntriesByType("navigation");
(function(){
if (perfEntries[0].type === "back_forward") {
location.reload(true);
}
}());
This is a function that doesn't require to be called, the function calls itself when the JS file is loaded
Going back to previous page using javascript
According to this all major browsers are supported
How Do I go back to my html page without losing the index of it?
You need to save the state in a storage, for example a sessionStorage
.
You can handle it with the onload Event
.
You need to save the state in the storage when the button is clicked to show the image. And when the page reloads, check if the button is clicked, if so then show the container else don't show.
const showImage = () => {
sessionStorage.setItem('showImage', 'true');
document.getElementById("first").style.display ='block';
}
function myFunction() {
if (sessionStorage.getItem('showImage') === 'true') {
document.getElementById("first").style.display ='block';
sessionStorage.removeItem('showImage');
}
}
on the body tag add this:
<body onload="myFunction()">
For example:
https://jsfiddle.net/dn09ysa1/
Related Topics
How to Make New Line or Break in Array
Automatically Force Mobile Browser to Desktop View
How to Print Star Pattern in JavaScript in a Very Simple Manner
Select Value of Input Element Inside HTML Table Using Jquery
Regex to Get String Between Curly Braces
How to Redirect Drop Down Menu When Option Is Selected
Getting Internal Server Error (500) - Codeigniter
How to Run HTML File on Localhost
React Native Init Android,Ios and App Folder Missing
What Is the Best Method to Swap Words in a String
Angular Conditional Readonly/Disable on Input Fields
How to Check If a Cookie Exists
How to Mock Private Functions With Jest
Vue.Js - How to Call Method from Another Component
Find Minimum Numbers of Currency for Required Amount
Regex to Allow Only Certain Special Characters and Restrict Underscore