html select标签加链接3种方法

发布时间:2022-04-12 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了html select标签加链接3种方法脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
第一种

复制代码
代码如下:

<htML>
<head>
<;meta http-equiv="Content-tyPE" content="text/html; charset=gb2312" />
<tITle>select加链接</title>
</head>
<body>
<SCRIPT language=javascript>
<!--
// open the related site windows
function mbar(sobj) {
VAR docurl =sobj.options[sobj.selectedIndex].value;
if (docurl != "") {
open(docurl,'_blank');
sobj.selectedIndex=0;
sobj.blur();
}
}
//-->
</SCRIPT>
<Select onchange=mbar(this) name="select">
<OPTION selected>=== 合作伙伴 ===</OPTION>
<OPTION value="http://www.baidu.COM">百度</OPTION>
<OPTION value="http://www.163.com">网易</OPTION>
<OPTION value="http://www.flash8.net/">闪吧</OPTION>
</Select>
</body>
</html>

第二种

复制代码
代码如下:

<select name="pageselect" onchange="self.location.href=options[selectedIndex].value" >
<OPTION value="http://www.baidu.com">百度</OPTION>
<OPTION value="http://www.163.com">网易</OPTION>
</select>

第三种带跳转按钮的

复制代码
代码如下:

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>select选择-按钮跳转</title>
<script type="text/javascript">
function setsubmit()
{
if(mylink.value == 0)
window.location='http://www.baidu.com';
if(mylink.value == 1)
window.location='http://www.163.com';
if(mylink.value == 2)
window.location='http://www.sina.com';
}
</script>
</head>
<body>
<select name="mylink" id="mylink">
<OPTION value="0">百度</OPTION>
<OPTION value="1">网易</OPTION>
<OPTION value="2">新浪</OPTION>
</select>
<input type="button" id="BTn" value="提交" onclick="setsubmit(this)" />
</body>
</html>

脚本宝典总结

以上是脚本宝典为你收集整理的html select标签加链接3种方法全部内容,希望文章能够帮你解决html select标签加链接3种方法所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:htmlselect