html select标签加链接3种方法

建站知识 2021-07-02 22:42www.168986.cn长沙网站建设
第一种

复制代码
代码如下:

<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://.baidu.">百度</OPTION>
<OPTION value="http://.163.">网易</OPTION>
<OPTION value="http://.flash8./">闪吧</OPTION>
</Select>
</body>
</html>

第二种

复制代码
代码如下:

<select name="pageselect" onchange="self.location.href=options[selectedIndex].value" >
<OPTION value="http://.baidu.">百度</OPTION>
<OPTION value="http://.163.">网易</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://.baidu.';
if(mylink.value == 1)
window.location='http://.163.';
if(mylink.value == 2)
window.location='http://.sina.';
}
</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>

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by