一、在html 中。如果input标签是放在form表单中的话是会有历史记录的。

比如:

<!DOCTYPE html>
<html>
<head>
</head>
<body >
	 <form action="" method="post">
        <input type="text" name="text1" />
        <input type="text" name="text2" />
        <button type="submit">提交</button>
    </form>
    <input type="text" name="text3">
</body>
</html>

在这里插入图片描述
form表单里的两个input是会有历史记录的。

二、清除历史记录下拉框

如果我们不需要历史记录提醒可以:

方法一:

加入autocomplete=“off”

<!DOCTYPE html>
<html>
<head>
</head>
<body >
	 <form action="" method="post">
        <input type="text" name="text1" autocomplete="off"/>
        <input type="text" name="text2" autocomplete="off"/>
        <button type="submit">提交</button>
    </form>
    <input type="text" name="text3"/>
</body>
</html>

如果加入了autocomplete="off"依然没有生效,则需要检查你的input 标签中是否有name属性,没有则需要加入name属性。

方法二:

请参考:Chrome ignores autocomplete=“off”

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐