Javascript获得子页面变量的值
例:
page.html页面:
<html>
<head>
<title>This is a test</title>
</head>
<script type="text/javascript">
var count;
</script>
<body>
<iframe id="child" src="childPage.html" src="childPage"></iframe>
</body>
</html>
页面里嵌套了一个childPage.html页面。
在page中的count如何获得childPage页面的childCount值呢?
child.childCount这种方法貌似不行……
还是换一种思路吧,让childPage中的childCount等于page页面的count。如下:
<html>
<head>
<title>This is a test(child)</title>
</head>
<script type="text/javascript">
var childCount = parent.count;
<script>
<body>
<iframe id="child" src="childPage" src="childPage"></iframe>
</body>
</html>
这样在page页面直接就可以获得childPage页面的childCount的值。
相关文档:
对于WEB程序来说,前端(JavaScript)和后端(JSP/Servlet)是没法共用数据的,只能是后端程序(JSP)把数据输出,生成页面到
前端,这时候生成的页面中的JavaScript代码才有可能得到所谓jsp的数据。同样的,只有把JavaScript里的数据提交给后端JSP代
码,JSP程序中才能得到JavaScript的数据。
......
JavaScript运行代码框代码
<script language="JavaScript" type="text/JavaScript">
//运行文本域代码
function runEx(cod1) {
cod=document.all(cod1)
var code=cod.value;
if (code!=""){
var newwin=window.open(’’,’’,’’); //打开一个窗口并赋给变量newwin。 ......
1、无提示关闭窗口
<input type="button" onClick="window.opener = '';window.close();" value="IE6最简单的无提示关闭窗口" >
2、防止被人iframe
if (top.location != self.location)
{
top.location.href="http://www.34do.net";
}
3、判断一个对象存在不存在
document.all("a")==null(不存在)
......
JavaScript语言和Java语言是相关的,但它们之间的联系并不像想象中的那样紧密。
二者的区别体现在:
首先,它们是两个公司开发的不同的两个产品,Java是SUN公司推出的新一代面向对象的程序设计语言,特别适合于Internet应用程序开发;而JavaScrip ......
<html>
<head></head>
<script>
function ShowMenu(bMenu) {
document.all.idFinder.style.display = (bMenu) ? "none" : "block"
document.all.idMenu.style.display = (bMenu) ? "block" : "none"
idML.className = (bMenu) ? "cOn" : "cOff"
idRL.className = (bMenu) ? "cOff" : "cOn" ......