本文介绍了HTML iframe和javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个iframe,每个iframe显示两个不同的html页面。两个html页面都引用一个包含全局变量的常见javascript文件。如果我在html页面加载期间在一帧中设置该全局变量的值。是否可以使用相同的全局变量访问另一个iframe html页面?为什么或为什么不呢?

I have two iframes and each iframe show two different html pages. Both html pages refer to a common javascript file which contains a global variable. If I set the value of that global variable in one frame during html page load. Will the value be accessible using the same global variable to another iframe html page? why or why not?

推荐答案

没有。 JavaScript的范围空间的顶级是页面级别。但是,您可以使用 window.parent

No. The top level of JavaScript's scope space is the page level. However, you can access another page's scope by using window.parent

这篇关于HTML iframe和javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 23:47