admin管理员组文章数量:1405388
I have a radio button in my html:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="radio" name="r"/>
</body>
</html>
If I check it, and reload the page (Firefox 20.0.1) it will stay checked. But if I clear the cache (ctrl+f5) the button gets unchecked again.
Is there any way to make it consistent so that it always unchecks itself when the page is refreshed? Or do I need to involve javascript? I've tried with and without the name
property.
PS. I wasn't able to make a fiddle. Try it on a local file in order to reproduce it.
I have a radio button in my html:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="radio" name="r"/>
</body>
</html>
If I check it, and reload the page (Firefox 20.0.1) it will stay checked. But if I clear the cache (ctrl+f5) the button gets unchecked again.
Is there any way to make it consistent so that it always unchecks itself when the page is refreshed? Or do I need to involve javascript? I've tried with and without the name
property.
PS. I wasn't able to make a fiddle. Try it on a local file in order to reproduce it.
Share Improve this question asked May 7, 2013 at 9:09 JohanJohan 35.2k62 gold badges188 silver badges305 bronze badges 4- AFAIK there's no way to do this crossbrowser without JS...I may be wrong tho. – elclanrs Commented May 7, 2013 at 9:11
- @elclanrs I was afraid that this es down to individual browser behaviour... – Johan Commented May 7, 2013 at 9:13
- I think, you have to use javascript for this. clearing cache is a bad practice, as most of the sites depend on it. – dreamweiver Commented May 7, 2013 at 9:14
- 2 Here is a fiddle that reproduced the problem in my Firefox. – ValarDohaeris-fuck-OpenAI Commented May 7, 2013 at 9:17
1 Answer
Reset to default 7You can set autoplete="off"
:
<input type="radio" name="r" autoplete="off" />
Please check this documentations:
Mozilla Dev
W3C
And working example: http://fiddle.jshell/2fAuY/2/show/ (thank you @ValarDohaeris for fiddle)
本文标签: javascriptKeep single radio button unchecked on page loadStack Overflow
版权声明:本文标题:javascript - Keep single radio button unchecked on page load - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744282722a2598732.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论