2007年04月19日(木) [過去の今日]
#1 submit is not a function の謎
海外のblog などにはあるのだが、日本語の情報がなかったのでここにメモしておこう。
どうやらidやname属性が "submit" になってる部品があると、JavaScriptのFormオブジェクトのsubmit()が上書きされる模様。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>submit is not a function</title> </head> <body> <p> <form name="myForm" method="POST" action="/hoge"> <input type="text" name="hoge" value="hogehoge" /> <input type="button" name="submit" value="Go!" onclick="document.myForm.submit();" /> </form> </p> </body> </html>
こんな感じ。
まあ考えてみれば当たり前なんだけどねい。あたりまえすぎて誰も書いてないのかなあ。
(@316)