2012-11-28 340 views
3

我想制作一个不错的幻灯片,首先对文章进行评分,然后关闭评分框以查看视频。我上的Joomla这样做的,使用此代码一点编辑:http://jsfiddle.net/AetnV/72/Jquery&Joomla无故障故障

这是我的代码版本: (问题是静态的HTML页面(非的Joomla)它的作品完美,但不是的Joomla我有上的JavaScript和iframe从JCE和全局配置,但仍然没有列入黑名单,禁止,我想这也与其他主题的相同。

<script type='text/javascript' src='http://code.jquery.com/jquery-1.5.2.js'></script> 

    <link rel="stylesheet" type="text/css" href="/css/normalize.css"> 
    <link rel="stylesheet" type="text/css" href="/css/result-light.css"> 

    <style type='text/css'> 
    * { margin: 0; padding: 0; outline: none; } 

body { background: #CCC; margin: 0; padding: 0; font: 10px normal Arial, Helvetica, sans-serif; } 

/*--Main Image Area--*/ 
.main_image { 
    margin: 20px 0 0 20px; width: 650px; height: 400px; 
    float: left; background: white; position: relative; overflow: hidden; 
    color: #fff; 

    moz-box-shadow: 0px 0px 4px #666; 
    -webkit-box-shadow: 0px 0px 4px #666; 
    box-shadow: 0px 0px 4px #666; 
} 

.main_image h2 { font-size: 2em; font-weight: normal; margin: 0 0 5px; padding: 10px; } 
.main_image p { font-size: 1.2em; padding: 10px; margin: 0; line-height: 1.6em; } 
.main_image .desc { position: absolute; bottom: 0; left: 0; width: 100%; display: none;} 
.main_image .block { height: 410px; width: 100%; background: #111; border-top: 1px solid #000; } 
.main_image a.collapse { 
    background: black; height: 30px; width: 650px; 
    position: absolute; top: -30px; right: 0px; 
    font: normal 12px arial; color: white; text-align: center; 
} 
.main_image a.show { background-position: left bottom; } 
    </style> 



<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){ 
$(document).ready(function() { 

    //Show Banner 
    $(".main_image .desc").show(); //Show Banner 
    $(".main_image .block").animate({ opacity: 1 }, 1); //Set Opacity 


    //Toggle Teaser 
    $("a.collapse").click(function(){ 
     $(this).next().slideToggle(); 
     $(this).toggleClass("show"); 
    }); 


});//Close Function 
});//]]> 

</script> 


    <div class="main_image"> 
<br><br><br><br><br><br> 
<center><img src="http://upload.macromedia.com/exchange/flash/previews/300x200_200x200.jpg" width=205" height="205"></a></center> 
    <div class="desc" style="display: block; "> 
     <a href="#" class="collapse show">Click Me!</a> 
     <div class="block" style="opacity: 1; display: none; "> 

      <center><br><br><br><iframe width="420" height="315" src="http://www.youtube.com/embed/AxcM3nCsglA" frameborder="0" allowfullscreen></iframe></iframe> 
      </center> 
     </div> 
    </div> 
</div> 

任何帮助是极大的赞赏。 谢谢

*此外,如果你有一个更好的方法来建议做我想做的事情 请告诉我。我在想,使其2divs和一个的onclick将重叠另一个,但我怕蜘蛛的我第一次尝试思考它的隐藏文字等。

+0

你做了什么错误? – Toretto

+0

它没有工作,我点击按钮来显示歌曲视频,但它没有显示它。它就像一个盲目的按钮。当在一个简单的.html页面上工作正常。 –

回答

1

尝试已被使用,请将其删除。

如果使用$doc = JFactory::getDocument();,那么在上面的代码,改成这样:

$doc->addScriptDeclaration($js);

+0

嗨,谢谢你的回复,我应该如何添加这个?我应该把它替换到什么地方吗?我没有使用javascript。: –

+1

你有没有为这个滑块做过扩展,或者是简单地将代码添加到你的index.php中你还可以提供一个链接到你的网站? – Lodder

+0

我只是简单地在文章中添加这个代码(这是一个坏主意?)我应该怎么做? :(目前正在开发中的本地主机:( –

0

取而代之的是代码 -

<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){ 
$(document).ready(function() { 

    //Show Banner 
    $(".main_image .desc").show(); //Show Banner 
    $(".main_image .block").animate({ opacity: 1 }, 1); //Set Opacity 


    //Toggle Teaser 
    $("a.collapse").click(function(){ 
     $(this).next().slideToggle(); 
     $(this).toggleClass("show"); 
    }); 


});//Close Function 
});//]]> 

</script> 

尝试这个 -

$document = JFactory::getDocument(); 
$js = ' $(document).ready(function() { 

      $(".main_image .desc").show(); 
      $(".main_image .block").animate({ opacity: 0.85 }, 1); 

      $("a.collapse").click(function(){ 
       $(this).next().slideToggle(); 
       $(this).toggleClass("show"); 
      }); 

     }); '; 
$document->addScriptDeclaration($js); 

如果$document = JFactory::getDocument();是:用以下

<script type='text/javascript'>//<![CDATA[ 
var $j = jQuery.noConflict(); 
$(window).load(function(){ 

});//]]> 
$j(document).ready(function() { 

    //Show Banner 
    $j(".main_image .desc").show(); //Show Banner 
    $j(".main_image .block").animate({ opacity: 1 }, 1); //Set Opacity 


    //Toggle Teaser 
    $j("a.collapse").click(function(){ 
     $j(this).next().slideToggle(); 
     $j(this).toggleClass("show"); 
    }); 


});//Close Function 
</script> 
+0

感谢您的回复,我只是试了一下,但没有奏效。它没有改变到音乐视频,它保持在第一个。 :( –

+0

@StanMarsh:你是否在控制台中发现任何错误? – Irfan

+0

没有关于jQuery,我试过它也只是现在在一个全新的Joomla安装没有任何其他的东西,你会推荐任何其他方式来实现你看到的结果这个吗? –