document获取父页面的对象
来源:互联网 发布:windows vista精简版 编辑:程序博客网 时间:2024/05/17 22:22
今天在做一个简单的例子的时候遇到了一个问题
首先这个例子就是点击图片,执行函数,submit表单之后,转到另一个jsp页面
我用的是js写的,但是点击玩按钮之后能出现111的弹窗,却没有出现转换到那个页面
index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><%/*String path = request.getContextPath()ISO-8859-1;String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";System.out.println("hello");*/%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> </head> <script language='javascript' src='test.js'></script> <body> <h1>用户登录</h1> <hr> <form action="as1.jsp" method="post" name='myform'> <input type='radio' name='sex' checked>nan <input type='radio' name='sex'>nv <br> <input type='radio' name='oo'>1 <input type='radio' name='oo'>2 <input type='radio' name='oo'>3 <input type='radio' name='oo'>4<br> <img src='button.jpg' style='width: 10% ;height:10%' onclick='fun()'> </form> </body></html>
test.js
'use strict'function fun(){alert('1111')window.parent.document.myform.submit();}
window.parent.document.myform.submit();这里一开始是这样写的
document.myform.submit();这里的document指的是test.js这个页面的对象,并非指之前的index.jsp,所以调用myform也就是空了
或者把这段代码写到index里也是可以实现的
0 0
- document获取父页面的对象
- document获取页面控件的标签对象
- 获取页面window/document的值
- document.getElementsByTagName(“#”)获取的对象的集合
- document节点对象的获取方式
- jquery获取iframe的document对象
- document获取对象的三种三方法
- 获取Document对象
- 父窗口获取iframe子窗口window对象和document对象的方法
- (JS错误)document对象操作,获取对象的错误
- 子页面与父页面元素对象之间的获取
- layui父页面获取子页面的窗口对象
- WebBrowser之获取跳转页面的Document接口源码
- document获取对象三方法
- c++builder中使用TWebBrowser获取document对象的方法
- document.getElementById获取控件对象为空的解决方法
- 获取iframe节点元素里的document对象
- iframe子页面获取父页面对象
- 对计算机的认识与感想
- PHP链接插入数据
- linux内核中分配4M以上大内存的方法
- 两人过桥
- 求结点数位n的 二叉排序树个数
- document获取父页面的对象
- shiro开发框架
- 名利虚荣与形而上的价值取向
- 朴素的DFS——数的排列问题
- 其他信息: 对一个或多个实体的验证失败。有关详细信息,请参见“EntityValidationErrors”属性。
- 求第1500个丑数的精炼算法(转自 算法竞赛入门经典 第二版)
- windos下wampserver多php版本切换
- java中的自增和自减运算符
- Python Django的使用:Writing your first Django app--实践