html的几个问题

xiaoxiao2021-03-01  7

1 type为submit类型的input被disabled掉后导致form不能submit 看下面这个html <form action=""> <div> <input type="submit" value="submit3" onclick="this.disabled=true;return true;"></input> </div></form> 这样的做法本来是为了防止重复提交,结果发现在某些浏览器下,input被disable了,但是form没有提交. 查了下w3的规范根本没提submit类型的input被disable后,是不是应该影响form的提交.看来每个浏览器都是自作主张,自行其是. 2 isNaN函数和空字符串 本来想用isNaN函数来判断是否是数字,结果isNaN("")的结果是false.因为null和""都是能转化为0的 [quote] Note: If the value being evaluated is null or an empty string, isNaN returns false because both null and empty string evaluate to 0. [/quote] 3 js函数和form元素重名导致函数不能执行 比如下面这个input,点击后不能执行,firebug里显示TypeError: crap is not a function <form action=""> <div> <input type="button" id="crap" onclick="crap();"/> </div> </form> 这个问题真是说来话长,请看 [url]http://stackoverflow.com/questions/1415747/javascript-function-and-form-name-conflict[/url] [url]http://stackoverflow.com/questions/9158238/why-js-function-name-conflicts-with-element-id[/url] 4 input在firefox中的自动完成 比如一个普通的form <form action=""> <div> <input name="crap" value="33"/> </div> </form> 在火狐里,如果把input填上值,然后刷新,发现上次填上的值还是在的 要用<input name="crap" value="33" autocomplete="off"/>这种手段禁用firefox的自动完成
转载请注明原文地址: https://www.6miu.com/read-3350183.html

最新回复(0)