繁体   English   中英

Mozilla Firefox innerhtml无法正常工作

[英]Mozilla Firefox innerhtml not working

我正在使用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>

那是我的代码,一点点的css,一个函数和主体。 正如我所说,其他浏览器也可以正常工作。 他们通常向我确切地显示innerhtml 但是Firefox不能,黑色覆盖效果很好。 检查javascript时没有错误,没有消息。

I'ts不是innerhtml问题,它的<embed>标记。 它不是打开网页,而是打开视频。 您应该尝试使用<iframe>类的东西。

您的代码在mozilla firefox中正常运行。

我在这个小提琴中使用了它: WORKING FIDDLE,并添加了以下代码: console.log($('#displaybox').html()); 我得到的答案是: <embed src="https://www.google.com/" height="638" width="1024"> ,这与我提供的相同输入是正确的。

当我查看Firebug中的ID displaybox时,我能够看到嵌入在该ID中的embed代码。

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

我遇到了同样的问题。 解决方案是,您可以使用.value而不是.innerHTML从Divs获取值。 这将最适合您将使用的任何一种浏览器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM