for i as int32 to dropdownlist1.items.count-1 dropdownlist1.items(i).attribute.add("onchang","window.open('"& this.value &"','','toolbar=no,menubar=no');") next
Dim item1 As New ListItem item1.Text = "新浪" item1.Value = "http://www.sina.com.cn" Dim item2 As New ListItem item2.Text = "网易" item2.Value = "http://www.163.com" Me.DropDownList1.Items.Add(item1) Me.DropDownList1.Items.Add(item2) Me.DropDownList1.Attributes.Add("onchange", "window.open(this.value,'','');")
{
Response.Write("<script>window.Open('"+要打开页面的uri+"')</script>");
}
dropdownlist1.items(i).attribute.add("onchang","window.open('"& this.value &"','','toolbar=no,menubar=no');")
next
this.DropDownList.Attributes.Add("onchange","window.open(this.value,'','');");
其中,这个下拉框的值,必须为如下
<option value="http://www.sina.com.cn">新浪</option>
item1.Text = "新浪"
item1.Value = "http://www.sina.com.cn"
Dim item2 As New ListItem
item2.Text = "网易"
item2.Value = "http://www.163.com"
Me.DropDownList1.Items.Add(item1)
Me.DropDownList1.Items.Add(item2)
Me.DropDownList1.Attributes.Add("onchange", "window.open(this.value,'','');")
{
//this.DropDownList1.Attributes.Add("onchange","window.open(this.value,'','');");
this.DropDownList1.Attributes.Add("onchange","openvalue(this,this.value)");
string js=@"<script langugae=""javascript"">";
js += @" function openvalue(selobj,selvalue)";
js += @"{";
js += @"alert('aaaa');";
js += @"if (selobj.value!="""")";
js += @"{";
js += @"window.open(selvalue);";
js += @"selobj.selectedIndex=0;";
js += @"}";
js += @"}";
js += @"</script>";
this.RegisterClientScriptBlock("onchange",js);
}
dropdownlist1的autopostback=false;
<option value="http://www.zzu.edu.cn" selected>郑州大学</option>
<option value="http://news.163.com">网易</option>
<option value="http://www.csdn">csdn</option>
</SELECT>
<button onclick="if(document.getElementById('home').selectedIndex==1) return;location=document.getElementById('home').value"
type="button">go </button>
这短代码为什么编译不过去?
levin9(工作电脑不能上网) 的可以,谢谢
试试,//DropDownList写成你的控件名,编译是没问题的,如果JS有错那就是可能selectItem写错了