Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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 Js显示和隐藏函数_Javascript_Jquery - Fatal编程技术网

Javascript Js显示和隐藏函数

Javascript Js显示和隐藏函数,javascript,jquery,Javascript,Jquery,我知道有很多脚本可以显示和隐藏内容,但在我的场景中没有一个适合我。 在这个测试页面上 我在iframe中有flash游戏,如果你点击PLAY按钮或不点击静止按钮,flash内容将开始在Chrome和IE中加载(不是在firefox中) 因此,为了应对这种情况,我考虑使用显示和隐藏内容的方法,并使用了一些脚本,但它们都没有帮助,因为即使在我使用它们时,flash内容仍然用于在IE和Chrome的后端加载。 我想要的是一个脚本,它在执行“onclick”功能之前不会让flash内容加载。 我知道有一

我知道有很多脚本可以显示和隐藏内容,但在我的场景中没有一个适合我。 在这个测试页面上 我在iframe中有flash游戏,如果你点击PLAY按钮或不点击静止按钮,flash内容将开始在Chrome和IE中加载(不是在firefox中)

因此,为了应对这种情况,我考虑使用显示和隐藏内容的方法,并使用了一些脚本,但它们都没有帮助,因为即使在我使用它们时,flash内容仍然用于在IE和Chrome的后端加载。 我想要的是一个脚本,它在执行“onclick”功能之前不会让flash内容加载。 我知道有一个脚本可以实现这种“懒散加载”,但它是用于图像的,我不认为它也适用于flash内容

注意:1-提供的链接上有音乐 2-很抱歉提供blogspot链接,但是对于生活在阿富汗的5KBps的人来说,JSFIDLE不是一个选项

相关标记: 灯箱或模式窗口的按钮

<a class="poplight" href="#?w=100%" rel="popup_name"><img alt="play game" class="happybutton" onmouseout="this.style.opacity=0.8;this.filters.alpha.opacity=80" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" src="http://farm5.static.flickr.com/4084/4998558471_27e3985c16_m.jpg" style="opacity: 0.8;" /></a>
JS(实际上是Jquery)


您应该尝试这样的方法,在单击按钮后立即加载帧:

$(document).ready(function(){
    $('a.poplight[href^=#]').click(function() {
        $('<iframe/>')
            .attr('frameborder', 0)
            .attr('allowTransparency', false)
            .attr('scrolling', 'no')
            .attr('width', '100%')
            .attr('height', '98%')
            .attr('src', 'http://files.cryoffalcon.com/bhgames/dressup/Celebrities/Wizard%20Fashion.html')
            .appendTo('#popup_name');
    });
});

因此,问题实际上是:我如何使用javascript加载flash内容,对吗?@t好吧,flash内容加载了,它没有问题,我所做的只是停止加载,让它只在我们单击播放按钮时加载。为什么不在单击播放按钮时动态添加iframe?这对我来说是个好主意,你能不能给我一个完整的答案,这样我就可以知道该怎么做,因为我在编码方面有点弱,因为我是注册会计师。(但我喜欢编程)@Dmitryy Chekalyuk感谢您的回复,但您可以看到,我现在拥有完整的代码,在上面提供的相同链接中,它不起作用。去谷歌chrome上使用它,然后加载游戏,它就会开始发出声音,即使你关闭它,它就像最小化未关闭一样。@CryOfFaclon,我明白了。关闭按钮将动态添加到div中,因此必须使用.live('click')而不是.click()。见更新的答案。我已经做了我所说的。但若你们不介意的话,你们可以在IE8中看到,点击播放按钮打开它,然后关闭,做3到4次,你们会看到有时候它会显示一个黑屏。如果你知道或者如何解决这个问题,这都是你的选择。这一次,我真的很感谢你,你是一个很棒的人。基于这个问题,你想在这个问题上帮助我吗?
#fade { 
    display: none; 
    background: #000;
    position: fixed; left: 0; top: 0;
    width: 100%; height: 100%;
    opacity: .80;
    z-index: 9999999;
}

.popup_block{
   width: 98.95%; height: 98.2%;
    display: none;
    padding: 0px;
    line-height:1em;
    font-size: 1em;
    position: fixed;
    top: 0px; left: 0px;
    z-index: 999999999;
    -webkit-box-shadow: 0px 0px 20px #000;
    -moz-box-shadow: 0px 0px 20px #000;
    box-shadow: 0px 0px 20px #000;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
}
.close {
    height:20px;
    float: right;
    margin: 0 2px 0 0;   
}
&lt;script type=&quot;text/javascript&quot;&gt;
    $(document).ready(function(){

        //When you click on a link with class of poplight and the href starts with a # 
        $(&#39;a.poplight[href^=#]&#39;).click(function() {
            var popID = $(this).attr(&#39;rel&#39;); //Get Popup Name
            var popURL = $(this).attr(&#39;href&#39;); //Get Popup href to define size

            //Pull Query &amp; Variables from href URL
            var query= popURL.split(&#39;?&#39;);
            var dim= query[1].split(&#39;&amp;&#39;);
            var popWidth = dim[0].split(&#39;=&#39;)[1]; //Gets the first query string value

            //Fade in the Popup and add close button
            $(&#39;#&#39; + popID).fadeIn().css({ &#39;width&#39;: Number( popWidth ) }).prepend(&#39;&lt;a href=&quot;#&quot; title=&quot;Close It&quot; class=&quot;close&quot;&gt;&lt;img src=&quot;http://files.cryoffalcon.com/bloghuts/images/close%20button.png&quot; alt=&quot;Close&quot; width=&quot;20&quot; height=&quot;20&quot; /&gt;&lt;/a&gt;&#39;);

            //Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
            var popMargTop = ($(&#39;#&#39; + popID).height() + 0) / 0;
            var popMargLeft = ($(&#39;#&#39; + popID).width() + 0) / 0;

            //Apply Margin to Popup
            $(&#39;#&#39; + popID).css({ 
                &#39;margin-top&#39; : -popMargTop,
                &#39;margin-left&#39; : -popMargLeft
            });

            //Fade in Background
            $(&#39;body&#39;).append(&#39;&lt;div id=&quot;fade&quot;&gt;&lt;/div&gt;&#39;); //Add the fade layer to bottom of the body tag.
            $(&#39;#fade&#39;).css({&#39;filter&#39; : &#39;alpha(opacity=80)&#39;}).fadeIn(); //Fade in the fade layer 

            return false;
        });


        //Close Popups and Fade Layer
        $(&#39;a.close, #fade&#39;).live(&#39;click&#39;, function() { //When clicking on the close or fade layer...
            $(&#39;#fade , .popup_block&#39;).fadeOut(function() {
                $(&#39;#fade, a.close&#39;).remove();  
        }); //fade them both out

            return false;
        });


    });

    &lt;/script&gt;
$(document).ready(function(){
    $('a.poplight[href^=#]').click(function() {
        $('<iframe/>')
            .attr('frameborder', 0)
            .attr('allowTransparency', false)
            .attr('scrolling', 'no')
            .attr('width', '100%')
            .attr('height', '98%')
            .attr('src', 'http://files.cryoffalcon.com/bhgames/dressup/Celebrities/Wizard%20Fashion.html')
            .appendTo('#popup_name');
    });
});
$('#popup_name .close').live('click', function() {
    $('#popup_name iframe').remove();
});