您的位置:首页 > Web前端 > HTML

HTML -- input 元素的type属性的秘密

2009-09-17 19:49 459 查看
今天在做完paypal跳转程序后,注释了一下zen cart的支付提交按钮,一个表单加一个type值为image的按钮,点击按钮提交表单,我对image的input元素不是很熟悉,通常要么是用type为submit的input元素,要么就是定义一个事件通过脚本来提交
。但是我找了半天也没发现有定义事件,没有onclick属性,也没有通过js动态绑定事件。奇怪了半天,我想会不会是在form中如果只有一个按钮时默认就是用来提交。我就把整个表单代码复制出来,在本地测试,修改ID,NAME属性,最好才知道type为image时才会自动提交。查了一下《HTML & XHTML: The Definitive Guide, 6th Edition》(我比较喜欢参考的书,基本上找什么都有),找到如下字段:

The image type of form <input> element is a special submit button made out of a picture that, when selected by the user, tells the browser to submit the form to the server. Upon submission, the browser also includes the X,Y coordinates of the mouse pointer within the image in the form's parameter list, much like the mouse-sensitive image maps we discussed in Chapter 6.

搞了半天,type为image的input元素是type为submit的一个特殊情况,还需要进一步学习。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: