开发者

How to maintain checkbox disabled state when returning to page using Back?

I'm having difficulty maintaining the disabled state of a check box when going back in the browser.

I've create these two sample pages to demonstrate my issue.

What do I need to do in order to ensure the checkbox remains disabled when returning to the previous page?

test1.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <form id="test" action="/">
        System <input type="checkbox" id="chkSystem148" onclick="this.disabled = true;"/>
        <a href="test2.html">Go to test2</a>
    </form>
</body>
</html>


test2.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <inpu开发者_开发百科t type="button" value="Go Back" onclick="history.back(-1); return false;" />
</body>
</html>


As mblase75 commented, use cookies. or other form of persistent storage, like localstorage. a hash might also work, don't remember on the spot if that adds to the history or if only in newer browsers that allow to push items to the history.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜