如何编写一个javascript函数来加载一个显式的超大幻灯片
我如何编写一个名为showSlideTwo()的javascript函数来调用超大的api并更改幻灯片? 我试过了
$( “#超大型”)api.goTo(2)。
要么
$ .supersized.api.goTo(2);
它在chrome中给了我以下消息:“无法调用方法’goTo’的undefined”
非常感谢你。
这是我详细尝试的内容:
这是一个完整的html页面,定义了两张幻灯片。 单击链接应该更改为幻灯片2(我甚至尝试了nextSlide()),它不起作用。 api似乎可用,因为可以读取标题并使用警报正确显示。
jQuery(function($){ $.supersized({ // Background image slides : [ { image : 'http://sofzh.miximages.com/javascript/662880103_b3e1591d50_b.jpg', title : 'title image A' }, { image : 'http://sofzh.miximages.com/javascript/6080023793_b965ab5702_b.jpg', title : 'title image B' }, ], transition : 1, vertical_center : 1, autoplay: 0, slideshow: 0 }); }); #supersized { position:fixed; left:0; top:0; overflow:hidden; z-index:-999; height:100%; width:100%; } #supersized img{ width:auto; height:auto; position:relative; outline:none; border:none; } #supersized a { z-index:-30; position:fixed; overflow:hidden; top:0; left:0; width:100%; height:100%; background:#111; display:block; } #supersized a.image-loading { background:#111 url(../img/progress.gif) no-repeat center center; width:100%; height:100%; } #text_content, #text_content a {color: fff} Testpage:
click to show slide two $(document).ready(function(){ $("#testbutton").click(function(){ var slideTitle = api.getField('title'); alert(slideTitle); // correctly shows 'title image A', so the api call works api.goTo(2); // This does not switch the image as expected // api.nextSlide(); // -> does not do anyhting }); });
确保将新函数包装在jquery中,如下所示。 此外,超大化似乎添加了一个全局api对象。
http://buildinternet.com/project/supersized/docs.html#api_docs
好的,我知道了。 首先,函数api.goTo()仅适用于带有slideshow: 1
选项的超大对象slideshow: 1
。
然后它原来是一个CSS问题。 没有任何CSS我看到它生成包含图像的li标签。 所以,您只需要在上面的示例中添加以下CSS样式行(在更改选项之后(如果progress.gif图像不存在则无关紧要):
#supersized li {display:block; 列表样式:无; 的z-index:-30; 位置是:固定; 溢出:隐藏; 顶部:0; 左:0; 宽度:汽车; 高度:自动; 背景:#111; } #supersized li.prevslide {z-index:-20; } #supersized li.activeslide {z-index:-10;} #supersized li.image-loading {background:#111 url(../ img / progress.gif)no-repeat center center; 宽度:汽车; 高度:自动; } #supersized li.image-loading img {visibility:hidden; } #supersized li.prevslide img,#supersized li.activeslide img {display:inline; }
感谢任何想过这个问题的人。