加入如下代码
<form id="passwordForm">
<label for="pwd">Password:</label>
<input type="password" id="pwd" name="pwd">
<input type="submit" value="Submit">
</form>
<div id="content" style="display:none;">
<!-- 你的文章内容 -->
<p>这里是受保护的秘密内容。</p>
</div>
<script>
document.getElementById('passwordForm').onsubmit = function() {
if (document.getElementById('pwd').value === 'yourpassword') {
document.getElementById('content').style.display = 'block';
return false; // 防止表单提交
} else {
alert('Wrong password!');
}
};
</script>
Comments
Post a Comment