分享

网页制作 HTML中select选择菜单跳转“当前窗口”或“新窗口”

 cbhelp 2017-02-19

HTML中select选择菜单跳转“当前窗口”或“新窗口”

发布时间:2010-08-04 10:04
文章作者:Pop's Blog 

摘要:select选择菜单的链接方式主要由onchange来控制,下面是代码: 在新窗口中打开: select onchange = window.open(this.options[this.selectedIndex].value) name = select 在当前窗口打开: select onchange = 'document.location.href=this.options[this.se...

select选择菜单的链接方式主要由“onchange”来控制,下面是代码:

 

在新窗口中打开:
 

  1. <select onchange="window.open(this.options[this.selectedIndex].value)" name="select"> 

 

在当前窗口打开:
 

  1. <select onchange='document.location.href=this.options[this.selectedIndex].value;'> 

 

下面是实际应用中的完整代码,供大家参考

1、在新窗口中打开 示例代码:

 

  1. <select onchange="window.open(this.options[this.selectedIndex].value)" name="select"> 
  2. <option value="http://">Pop's Blog</option> 
  3. <option value="http://www.qq.com">Tencent</option> 
  4. <option value="http://www.google.com">Google</option> 
  5. </select> 

 

2、在当前窗口打开 示例代码:

 

  1. <select onchange='document.location.href=this.options[this.selectedIndex].value;'> 
  2. <option value="http://">Pop's Blog</option> 
  3. <option value="http://www.qq.com">Tencent</option> 
  4. <option value="http://www.google.com">Google</option> 
  5. </select> 

 


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多