2

我在 javascript 和 css 中也有问题。我有一个视频,只有当您依次点击 2 个广告时才会显示。

<script type="text/javascript">

function closead(a,background) {

    var e = document.getElementById(a);
    var bg = document.getElementById("background"); 

    bg.style.background = background + " no-repeat";
    bg.style.backgroundSize = "100% 100%";

    if(e.style.visibility == ""){ 
    e.style.display = "none";
    e.innerHTML=""; 

    }
} 
    </script>

<script type="text/javascript">

function habilitar(id,id2){ 
    var e = document.getElementById(id);
    var d = document.getElementById("body_logo");

    if(e.style.visibility == ""){ 
    e.style.visibility="hidden"; 
    e.innerHTML=""; 
    e.innerHTML 

    d.style.visibility== "";
    d.style.visibility="hidden";
    d.innerHTML="";

    jwplayer("container").setup({

    height: "97%",
    width: "100%",
    primary: "flash",

    allowscriptaccess: "always",
    autostart:true,

  playlist: [{
      image: "uploads/snapshots/374f9c59b58f880c5e68762bde43318a.jpg",
    sources: [{
      file: "uploads/374f9c59b58f880c5e68762bde43318a.mp4",
      label: "360p"
    },{
      file: "uploads/374f9c59b58f880c5e68762bde43318a.flv",
      label: "240p"
    }]
  }],  
});

    }


}
</script>

<div id="file_title" >
<a href="#" target="_blank"><strong>Game.of.Thrones.S03E06.HDTV.XviD.Dual.Audio.THESPEEDBR.COM</strong></a>
</div>
<div id="background" style="background-image:url('images/logomarca/video/embed_background.jpg'); width:100%; height:100%;">

<div id="body_logo" style="width:100%;">

<div style="position:absolute; top:8%; margin:0 auto; height:250px; height:100%; width:100%; z-index:2; " id="ad2">
<div id="propaganda2" >
                    <div class="player_hover">
                        <!-- BEGIN ATF 300PX X 250PX --><a href="#" target="_blank"><img src="images/videos_anuncios/propaganda-3.jpg" height="250" width="300" /></a>      
                     </div>
                    <form method="post">
                        <input type="hidden" value="bar" name="foo">
                        <input name="confirm" type="submit" onClick="habilitar('propaganda2');" value="Start Video Now" class="confirm_button" style="width:250px;">
                    </form>

</div>
</div>

<div style="position:absolute; top:8%; margin:0 auto; height:250px; height:100%; width:100%; z-index:2; " id="ad1">
<div id="propaganda1">
                    <div class="player_hover">
                        <!-- BEGIN ATF 300PX X 250PX --><a href="#" target="_blank"><img src="images/videos_anuncios/propaganda-3.jpg" height="250" width="300" /></a> 
               <img src="propaganda-3.jpg" height="250" width="300" />
                     </div>
                    <form method="post">

                        <input name="confirm" type="submit" onClick="closead('ad1','url(uploads/snapshots/374f9c59b58f880c5e68762bde43318a.jpg)');" value="Close Ad and Watch as Free User" class="confirm_button" style="width:250px;">
                    </form>   
            or <a href="admin/index.php?pagina=premium" target="_blank">Get Pro Account</a> to get rid of the ads

</div> 
</div>

</div>
<div  style="position:absolute; width: 100%; height: 100%">
<div id="container"></div>
</div>


</div>
</body>
</html>

在 mozilla 中完美运行,但在其他浏览器中无法正常运行,我无法确定问题所在。

如果有人想测试,这是我的 CSS

html, body {
    background-color:#000;
    margin:0px;
    padding:0px;
    height: 100%;
    width: 100%;
    overflow: hidden;

    font-family:"Lucida Grande","Lucida Sans Unicode","Lucida Sans",Helvetica,Arial,sans-serif;
    font-size:12px;
    line-height:22px;
    background-color:#000;

}

#container {

}

#file_title {
    color:#FFF;
    text-align:center;
    height:20px;
    padding:5px;

}

#file_title a {
    color:#39C;
    text-decoration:none;
    font-weight:bold;
}

#file_title a:hover {
    color:#FFF;
}

#propaganda1 {
    width:100%; 
    height:330px;
    text-align:center;
    font-size:12px;
    color:#CCC;
}

#propaganda2 {
    width:100%; 
    height:330px;
    text-align:center;
    font-size:12px;
    color:#CCC;
}

#propaganda1 a {
    color:#fff;
    text-decoration:underline;
}

#propaganda2 a {
    color:#fff;
    text-decoration:underline;
}
#propaganda strong {
    display:block;
    padding:5px;
    font-size:16px;
}

#propaganda strong a {
    color:#F60;
}

#propaganda strong a:hover {
    color:#F00;
}

.confirm_button {
    font-weight:bold;
    padding:4px;
    margin:3px auto;

}

#deleted, #disabled {
    width:400px;
    background-color:#000;
    text-align:center;
    color:#FFF;
    font-size:17px;
    padding:130px 10px 130px 10px;
    margin:30px auto;
    border:#CCC 1px solid;
}

#disabled a {
    color:#C00;
    display:block;
    margin:5px;
}
#disabled a:hover {
    color:#900;
}

#password_box {
    width:400px;
    background-color:#000;
    text-align:center;
    color:#FFF;
    font-size:17px;
    padding:110px 10px 110px 10px;
    border:#CCC 1px solid;
    margin:30px auto;
}
img#bg {
    position:absolute;
    z-index:-1;
}

.play_button {
    color:#FFF;
    font-weight:bold;
    line-height:30px;
}
.play_button strong {
    display:block;
    text-align:center;
    width:100px;
    margin:0px auto;
    color:#FFF;
}

.play_button a {
    width:90px;
    height:90px;
    display:block;
    background-image:url(../images/play_button.gif);
    background-repeat:no-repeat;
    background-position:-90px 0;
    margin:auto auto;
}

.play_button a:hover {
    background-position:0 0;
}
.video_player {
    margin:0px auto;
}

.player_hover_ad {
    width:300px;
    height:250px;
    background-color:#FFF;
    text-align:center;
    padding:5px;
    margin:10px auto 10px auto;
    -moz-border-radius:5px;  
    border-radius: 5px;  
    -webkit-border-radius: 5px;
}

#playdiv {
    width:100%;
    height:360px;
    text-align:left;
    padding:0px;
    color:#FFF;
    position:relative;
    z-index:1;
}

我设法修复了 css,但 javascript 不起作用。当我单击按钮时,Chrome 中的不关闭

4

1 回答 1

2

遇到此类问题时,通过jslintjshint运行 js 总是一个好主意- 它指出了许多可能导致 JS 跨浏览器问题的小错误。

当我给 jshint 你的 js 时:

function closead(a,background) {

    var e = document.getElementById(a);
    var bg = document.getElementById("background"); 

    bg.style.background = background + " no-repeat";
    bg.style.backgroundSize = "100% 100%";

    if(e.style.visibility == ""){ 
    e.style.display = "none";
    e.innerHTML=""; 

    }
} 


function habilitar(id,id2){ 
    var e = document.getElementById(id);
    var d = document.getElementById("body_logo");

    if(e.style.visibility == ""){ 
    e.style.visibility="hidden"; 
    e.innerHTML=""; 
    e.innerHTML 

    d.style.visibility== "";
    d.style.visibility="hidden";
    d.innerHTML="";

    jwplayer("container").setup({

    height: "97%",
    width: "100%",
    primary: "flash",

    allowscriptaccess: "always",
    autostart:true,

  playlist: [{
      image: "uploads/snapshots/374f9c59b58f880c5e68762bde43318a.jpg",
    sources: [{
      file: "uploads/374f9c59b58f880c5e68762bde43318a.mp4",
      label: "360p"
    },{
      file: "uploads/374f9c59b58f880c5e68762bde43318a.flv",
      label: "240p"
    }]
  }],  
});

    }


}

它给了我这份报告:

Errors:

Line 3: var e = document.getElementById(a);

Missing "use strict" statement.

Line 9: if(e.style.visibility == ""){

Expected '===' and instead saw '=='.

Line 18: var e = document.getElementById(id);

Missing "use strict" statement.

Line 21: if(e.style.visibility == ""){

Expected '===' and instead saw '=='.

Line 24: e.innerHTML

Expected an assignment or function call and instead saw an expression.

Line 24: e.innerHTML

Missing semicolon.

Line 26: d.style.visibility== "";

Expected '===' and instead saw '=='.

Line 26: d.style.visibility== "";

Expected an assignment or function call and instead saw an expression.

Line 30: jwplayer("container").setup({

'jwplayer' is not defined.

Line 1: function closead(a,background) {

'closead' is defined but never used.

Line 17: function habilitar(id,id2){

'habilitar' is defined but never used.

Line 17: function habilitar(id,id2){

'id2' is defined but never used.

我建议您修复这些错误,看看是否能解决您的问题。

于 2013-05-13T23:04:42.060 回答