input标签属性:链接页面前进后退back

发布于 2020-05-19  1.12k 次阅读  共 1068 字


<input> 标签用于搜集用户信息。根据不同的 type 属性值,输入字段拥有很多种形式。输入字段可以是文本字段、复选框、掩码后的文本控件、单选按钮、按钮等等。

HTML 与 XHTML 之间的差异

在 HTML 中,<input> 标签没有结束标签。

在 XHTML 中,<input> 标签必须被正确地关闭。

input链接页面前进后退代码实例

1.链接到某页

<input type="button" value="转跳" onclick="location.href='网址'" />

2.返回上一页(等同后退)

<input type="button" onclick="location.href='javascript:history.go(-1);'" value="后退" />

3.打开新网页 (在新标签打开)

<input type="button" value="打开" onclick="window.open('网址')" /> 

4.打开无边框的新窗口

<input type="button" value="打开" onclick="javascript:window.open('网址','','width=720,height=500,resizable=yes,scrollbars=yes,status=no')" /> 

5.打开新网页同时指向另一页

<input type="button" value="打开" onclick="window.open('网址');location.href='http://www.sey.ink'" />

6.打开无边框的新窗口同时指向另一页

<input type="button" value="打开" onclick="javascript:window.open('http://www.sey.ink','','width=720,height=500,resizable=yes,scrollbars=yes,status=no'); window.location='网址';" />

7.点击按钮弹出确认alert窗口

方法一:
<input type="button" value="转跳" onClick="*('是否确认转跳?');location.href='网址';return false;" >

*代表alert因为wp保存原因所以用*号代替 使用时记得替换

方法二:
<input type="button" value="转跳" onClick="if (confirm('是否确认转跳?'))location.href= '网址';return false;" >