I'm quite new to javascript programming and got stuck in this problem: I have a div displaying a map made with flash. This flash features a magnifying glass icon, that when clicked, calls this javascript:
我对javascript编程很新,并且遇到了这个问题:我有一个显示用flash制作的地图的div。这个闪光灯有一个放大镜图标,点击后,调用此javascript:
function turnMap()
{
DivSwitcher(map.id);
DivSwitcher(rightcolumn.id);
DivSwitcher(leftcolumn.id);
}
function DivSwitcher(layer)
{
if (document.getElementById(layer).style.display != "none")
document.getElementById(layer).style.display = "none";
else
document.getElementById(layer).style.display = "block";
}
All the called divs do exist, but the div with the map id is set with display: none
. On both IE and Chrome, this code works just fine: the divs get hidden or displayed as I want, but on Firefox, it doesn't happen. I tried running with FireBug to see what happens:
所有被调用的div都存在,但带有map id的div使用display:none设置。在IE和Chrome上,这段代码运行得很好:div被隐藏或显示为我想要的,但在Firefox上,它不会发生。我尝试使用FireBug运行,看看会发生什么:
map is not defined
地图未定义
If you guys could give me any leads I would appreciate it.
如果你们能给我任何线索我会很感激。
1 个解决方案
#1
3
That is because the JavaScript variable map
is not defined in the current scope, and that's all I can tell from your code.
那是因为JavaScript变量map没有在当前作用域中定义,而这就是我从代码中可以看到的。
My guess is that you are trying to access an element by calling its name, which is not supported. Maybe you can try:
我的猜测是你试图通过调用它的名字来访问一个元素,这是不受支持的。也许你可以尝试:
DivSwitcher('map');
DivSwitcher('rightcolumn');
DivSwitcher('leftcolumn');
#1
3
That is because the JavaScript variable map
is not defined in the current scope, and that's all I can tell from your code.
那是因为JavaScript变量map没有在当前作用域中定义,而这就是我从代码中可以看到的。
My guess is that you are trying to access an element by calling its name, which is not supported. Maybe you can try:
我的猜测是你试图通过调用它的名字来访问一个元素,这是不受支持的。也许你可以尝试:
DivSwitcher('map');
DivSwitcher('rightcolumn');
DivSwitcher('leftcolumn');