給Button/input添加鏈接,前進(jìn),后退等功能
來源:程序員人生 發(fā)布時間:2014-01-28 05:02:01 閱讀次數(shù):3649次
給Button/input添加鏈接,前進(jìn),后退等功能,看標(biāo)題,大家就應(yīng)該明白是怎么回事了,我們在日常的網(wǎng)頁制作中使用a超級鏈接最多,而給按鈕添加鏈接,有一部分朋友可能沒用到過,今天小編就把與button、input相關(guān)的鏈接,前進(jìn),后退,彈出確認(rèn)alert窗口等的代碼整理出來,希望對您有所幫助。
代碼如下:
1.鏈接到某頁
<input type="button" name="Submit" value="確 定" class="btn" onclick="location.href='http://www.vxbq.cn/down'" />
2.返回(等同后退)
<input name="Submit2" type="button" class="btn" onclick="location.href='javascript:history.go(-1);'" value="返 回" />
3.打開新網(wǎng)頁
<input type="button" name="Submit2" value="確 定" class="btn" onclick="window.open('filename.html')" />
4.打開無邊框的新窗口
<input type="button" name="Submit2" value="確 定" class="btn" onclick="javascript:window.open('http://bbs.liehuo.net','','width=720,height=500,resizable=yes,scrollbars=yes,status=no')" />
5.打開新網(wǎng)頁同時指向另一頁
<input type="button" name="Submit2" value="確 定" class="btn" onclick="window.open('filename.html');location." />
6.打開無邊框的新窗口同時指向另一頁
<input type="button" name="Submit2" value="確 定" class="btn" onclick="javascript:window.open('http://www.liehuo.org','','width=720,height=500,resizable=yes,scrollbars=yes,status=no'); window.location='filename.html';" />
7.點擊按鈕彈出確認(rèn)alert窗口
方式一:
<input type="button" name="Submit1" value="確定" class="btn"
onClick="alert('Liehuo_net提示:提交成功!');location.href= 'filename.html';return false;" >
方式二:
<input type="button" name="Submit2" value="確定" class="btn"
onClick="if (confirm('學(xué)院提示:是否確認(rèn)提交?'))location.href= 'filename.html';return false;" >
感謝您對學(xué)院的支持,歡迎提出寶貴意見!
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈