I know there's already an accepted answer to this question. But just to demonstrate how trivial it is for someone to "unhide" a button using display: none
, consider the following example:
- In the snippet below, I have a text input where you can type arbitrary JavaScript. Think of it like typing JavaScript into the console.
- I also have a hidden button that you can't see when you first run the snippet. It is hidden using
display: none
.
- Click "Run Snippet", then in the text input type (or copy/paste) this code:
document.getElementById("hiddenButton").style.display = "inline"
- The hidden button should now appear next to the "Run Code" button.
$("#submit").on("click", function () {
eval($("#js").val());
});
#hiddenButton {
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Enter some JavaScript:
<input id="js" type="text"/>
<button id="submit">Run Code</button>
<button id="hiddenButton">Hidden Button!</button>
But even more so, a user doesn't even have to "unhide" the button to click it. They could just simulate a click of the button using:
document.getElementById("hiddenButton").click();
So, if they view the document source, and see that the button exists but is hidden, they can still simulate a click event on the button.
The fact that the site is served over SSL doesn't matter. SSL protects data in transit. A button on a page is data at rest. StackOverflow is an HTTPS site, yet you can still execute the code I discuss above.