Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Mozilla Firefox innerhtml不工作_Javascript_Firefox_Innerhtml - Fatal编程技术网

Javascript Mozilla Firefox innerhtml不工作

Javascript Mozilla Firefox innerhtml不工作,javascript,firefox,innerhtml,Javascript,Firefox,Innerhtml,我面临firefox和innerhtml的问题。我不明白为什么它不工作:/Chrome、Opera、IE、Safari都很好,但Firefox <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <title>Dokument bez názvu&l

我面临firefox和
innerhtml
的问题。我不明白为什么它不工作:/Chrome、Opera、IE、Safari都很好,但Firefox

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <title>Dokument bez názvu</title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="css/styl.css">
    <script type='text/javascript' src='js/jquery-1.9.1.js'></script>
    <style>
        #displaybox
        {
            z-index: 10000;
            filter: alpha(opacity=100); /*older IE*/
            filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100); /* IE */
            -moz-opacity: 1; /*older Mozilla*/
            -khtml-opacity: 1; /*older Safari*/
            opacity: 1; /*supported by current Mozilla, Safari, and Opera*/
            position: fixed;
            top: 20px;
            left: 0px;
            width: 100%;
            height: 100%;
            color: #FFFFFF;
            text-align: center;
            vertical-align: middle;
        }
        body
        {
            font-family: Calibri;
        }
        .black_overlay
        {
            visibility: hidden;
            position: absolute;
            top: 0%;
            left: 0%;
            width: 100%;
            height: 100%;
            background-color: black;
            z-index: 1001;
            -moz-opacity: 0.7;
            opacity: .70;
            filter: alpha(opacity=70);
        }
    </style>
    <script>
        function clicker() {
            var thediv = document.getElementById('displaybox');
            if (thediv.style.display == "none") {
                thediv.style.display = "";
                thediv.innerHTML = "<embed src='prohlidka.html' height='638' width='1024' ></embed>";
                var thelay = document.getElementById('fade');
                thelay.style.visibility = "visible";
            } else {
                thediv.style.display = "none";
                thediv.innerHTML = '';
                var thelay = document.getElementById('fade');
                thelay.style.visibility = "hidden";
            }
            return false;
        }

    </script>
</head>
<body>
    <div id="fade" class="black_overlay">
    </div>
    <div id="displaybox" style="display: none; overflow: visible">
    </div>
    <a id="otevrit" href='#' onclick='return clicker();'>Virtuální mapa</a>
</body>

多库门特·贝兹·纳兹武
#显示框
{
z指数:10000;
过滤器:alpha(不透明度=100);/*IE*/
过滤器:progid:DXImageTransform.Microsoft.Alpha(不透明度=100);/*IE*/
-moz不透明度:1;/*旧版Mozilla*/
-khtml不透明度:1;/*旧版Safari*/
不透明度:1;/*受当前Mozilla、Safari和Opera支持*/
位置:固定;
顶部:20px;
左:0px;
宽度:100%;
身高:100%;
颜色:#FFFFFF;
文本对齐:居中;
垂直对齐:中间对齐;
}
身体
{
字体系列:Calibri;
}
.黑色覆盖层
{
可见性:隐藏;
位置:绝对位置;
最高:0%;
左:0%;
宽度:100%;
身高:100%;
背景色:黑色;
z指数:1001;
-moz不透明度:0.7;
不透明度:.70;
过滤器:α(不透明度=70);
}
函数点击器(){
var thediv=document.getElementById('displaybox');
如果(thediv.style.display==“无”){
thediv.style.display=“”;
thediv.innerHTML=“”;
var thelay=document.getElementById('fade');
thelay.style.visibility=“可见”;
}否则{
thediv.style.display=“无”;
thediv.innerHTML='';
var thelay=document.getElementById('fade');
thelay.style.visibility=“隐藏”;
}
返回false;
}

这是我的代码,一点css,一个函数和主体。正如我所说的,其他浏览器工作正常。它们通常显示
innerhtml
我所需要的内容。但是Firefox没有,黑色覆盖效果很好。检查javascript时没有错误,没有消息。

问题不在于
innerhtml
,而是
标记。它不是用来打开网页,而是用来打开视频。相反,您应该尝试使用类似于

的东西,因为您的代码在mozilla firefox中工作正常

我在这把小提琴中使用了它:,并添加了这行代码:
console.log($('#displaybox').html())我得到的答案如下:
,这是正确的,因为我提供了相同的输入

当我在firebug中查看id
displaybox
时,我能够看到
embed
代码嵌入到该id中


因此,从技术上讲,代码没有问题,但是如果您当时想打开页面,那么您的
逻辑
错误的
。您必须使用
iframe src
而不是
embed
来打开页面

我也遇到了同样的问题。解决方案是,您可以使用.value而不是.innerHTML从div中获取值。这将非常适合您使用的任何类型的浏览器。

我用iframe替换了embed,效果很好:D非常感谢。它还解决了我的其他问题^^@user3197269:很高兴能帮上忙:)