Javascript 无法访问全局变量(语法错误?)
故事:我有三个文件,Javascript 无法访问全局变量(语法错误?),javascript,html,syntax,Javascript,Html,Syntax,故事:我有三个文件,Base.html,miniChallenge.html和miniChlgame.html。。。我用以下代码在Base.html中声明了一个全局变量(希望这样做是正确的): window.opener.document.clgteam.value = chkedRadio; Base.html 其中chkedRadio是所选单选按钮的值 之后,当用户单击确认框上的OK按钮时,iframe将加载miniChlgame.html,其中有两个标签,其中一个标签应显示“clgt
Base.html
,miniChallenge.html
和miniChlgame.html
。。。我用以下代码在Base.html
中声明了一个全局变量(希望这样做是正确的):
window.opener.document.clgteam.value = chkedRadio;
Base.html
其中chkedRadio是所选单选按钮的值
之后,当用户单击确认框上的OK按钮时,iframe将加载miniChlgame.html
,其中有两个标签,其中一个标签应显示“clgteam”的值(James88),我使用以下代码执行此操作:
document.getElementById('awayteam').innerHTML = window.opener.document.clgteam.value;
其中“awayteam”是标签的ID
但是,它不起作用,我尝试过各种方法。请开导我
(我对HTML、CSS和JavaScript完全陌生,请原谅我的愚蠢。我在网上搜索过,看到过各种解决方案,但我仍然无法采用它们来解决我的问题。)
无法工作,因为clgteam
不是HTML元素
根据浏览器功能(HTML 5或非HTML 5),您可以使用iframe通信来实现这一点。如何指向全局变量“clgteam”?有什么建议吗?
document.getElementById('awayteam').innerHTML = window.opener.document.clgteam.value;
window.opener.document.clgteam.value = chkedRadio;