1、代码实例

<!DOCTYPE html>
<html>
<head>
<title>选择并转移导航菜单</title>
<meta charset="utf-8">
</head>
<body>
<form method="post" action="select.html">
<select id="newLocation">
<option selected>select a topic</option>
<option value="script01.html">javascript</option>
<option value="script02.html">jquery</option>
<option value="script03.html">jquery mobile</option>
<option value="script04.html">html5</option>
<option value="script05.html">css3</option>
</select>
</form>
</body>
</html> <script type="text/javascript">
window.onload = init;
window.unload = function(){};
function init(){
document.getElementById("newLocation").selectedIndex = ;
console.log(document.getElementById("newLocation").options);
document.getElementById("newLocation").onchange = jumpPage;
}
function jumpPage(){
var newLoc = document.getElementById("newLocation");
var newPage = newLoc.options[newLoc.selectedIndex].value;
if(newPage != ""){
window.location = newPage;
}
}
</script>

2、重点分析:

  2.1、window.onunload = function(){}:

    onunload 事件在用户退出页面时发生;

    

  2.2、selectedIndex:

selectedIndex 属性可设置或返回下拉列表中被选选项的索引号。

注释:若允许多重选择,则仅会返回第一个被选选项的索引号。

  2.3、options:

    删除被选中的项
    objSelect.options[objSelect.selectedIndex] = null;

    增加项

    objSelect.options[objSelect.length] = new Option("你好","hello");

    修改所选择中的项
    objSelect.options[objSelect.selectedIndex] = new
Option("你好","hello");

    得到所选择项的文本

    objSelect.options[objSelect.selectedIndex].text;

    得到所选择项的值

    objSelect.options[objSelect.selectedIndex].value; 

Form,选择并转移导航菜单的更多相关文章

  1. WEB入门.九 导航菜单

    学习内容 水平导航菜单 垂直导航菜单 下拉式导航菜单 能力目标 制作tab标签导航菜单 制作带箭头的导航菜单 制作带信息提示的导航菜单 制作垂直下拉导航菜单 制作水平下拉导航菜单 本章简介 上一章节中 ...

  2. 前端框架bootstrap 表单和导航菜单的 Demo(第二篇)

    表单: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <tit ...

  3. bootstrap02导航菜单

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  4. web标准(复习)--4 纵向导航菜单及二级弹出菜单

    今天我们开始学习纵向导航菜单及二级弹出菜单,包含以下内容和知识点: 纵向列表 标签的默认样式 css派生选择器 css选择器的分组 纵向二级列表 相对定位和绝对定位 一.纵向列表纵向列表或称为纵向导航 ...

  5. jquery和css3实现滑动导航菜单

    效果预览:http://keleyi.com/keleyi/phtml/html5/15/ 有都中颜色可供选择,请使用支持HTML5/CSS3的浏览器访问. HTML源代码: <!DOCTYPE ...

  6. 仿腾讯QQ竖直滑动导航菜单

    菜单就像qq软件的分组,鼠标经过自动显示相应组的内容. 效果体验网址:http://keleyi.com/a/bjad/nf86w2dv.htm 以下是源代码: <html> <he ...

  7. SharePoint 2013技巧分享系列 - 隐藏Blog和Apps左侧导航菜单

    企业内部网中,不需要员工创建Blog或者创建,安装SharePoint应用,因此需要在员工个人Web页面需要隐藏Blog或者Apps导航菜单, 其步骤设置如下: 该技巧适合SharePoint 201 ...

  8. Bootstrap页面布局16 - BS导航菜单和其响应式布局以及导航中的下拉菜单

    代码: <div class='container-fluid'> <h2 class='page-header'>导航</h2> <!-- .navrbar ...

  9. SharePoint自动化系列——Site/Web/List级别的导航菜单

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 需求:在不同的测试用例中,对脚本中不确定的因素需要和用户交互来确定,比如选择哪个site,选择哪个 ...

随机推荐

  1. win8中 cmd直接以管理员权限运行

    一.组合键 WIN+X   二.锁定到任务栏,方便以后快速启动     三.控制面板->控制中心     四.更改用户账户控制设置--调到最低 好了,点击任务栏的命令提示符

  2. Hadoop HBase概念学习系列之概念视图(又名为逻辑模型)(八)

    其实啊,我们把HBase想象成一个大的映射关系,再者,本来,HBase存储的数据可以理解为一种key和value的映射关系,但有不是简简单单的映射关系那种,因为比如有各个时间戳版本啊. 通过行键.行键 ...

  3. 安装配置maven私服-nexus

    1.ubuntu下的Bundle安装方式 1.1. 去官网下载安装包:http://www.sonatype.org/nexus/ 我这里下载的是:nexus-2.8.1-01-bundle.zip, ...

  4. c# 匿名函数与托付

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/han_yankun2009/article/details/26290779    在 2.0之前的 ...

  5. Hive学习之路 (十三)Hive分析窗口函数(一) SUM,AVG,MIN,MAX

    数据准备 数据格式 cookie1,, cookie1,, cookie1,, cookie1,, cookie1,, cookie1,, cookie1,, 创建数据库及表 create datab ...

  6. 私有仓库harbor安装包括https

    1. 下载离线的 harbor gz包 wget https://github.com/vmware/harbor/releases/download/v1.2.0/harbor-offline-in ...

  7. jQuery文字“橡皮圈“特效

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. java集合---迭代器iterator

    一:ArraryList  最终继承超级接口Collection,Colection接口继承Iterator接口. public interface Collection<E> exten ...

  9. 源码编译安装mysql-boost-5.7.16.tar.gz报错分析处理

    Plugin 'FEDERATED' is disabled.  mysqld: Table 'mysql.plugin' doesn't exist  [ERROR] Can't open the ...

  10. CAN总线实际运用分析问题。

    组态设计   人机交互  上位机  分布式控制系统  下位机  (单片机/PLC)  CAN总线用线缆   连接方式(手牵手,T型)    CAN总线接地(大地) http://bbs.gongkon ...