简体   繁体   English

如何使javascript在页面中运行两次?

[英]How to get javascript to run twice in a page?

I have two slideshows in one page using javascript http://www.flickrshow.com/static/scripts/flickrshow-7.2.min.js , but it only displays the first slideshow. 我使用javascript http://www.flickrshow.com/static/scripts/flickrshow-7.2.min.js在一个页面中有两个幻灯片,但它只显示第一个幻灯片。 Can javascript run twice in a page or how do I get it to display the two slideshows? javascript是否可以在页面中运行两次,或者如何显示两个幻灯片?

Here is the actual page http://giantmango.com/colors-2010-2-1192 . 这是实际的页面http://giantmango.com/colors-2010-2-1192 I am using this javascript http://www.flickrshow.com/static/scripts/flickrshow-7.2.min.js to display images from flickr on an iPad since flickr`s slideshow uses Flash. 由于flickr的幻灯片使用Flash,因此我正在使用此javascript http://www.flickrshow.com/static/scripts/flickrshow-7.2.min.js在iPad上显示flickr的图像。

<div class="theflickrshow" id="cesc">
   <p>Please enable Javascript to view this slideshow</p>
</div>

<script src="http://www.flickrshow.com/static/scripts/flickrshow-7.2.min.js"></script>
   <script>
        var cesc = new flickrshow('cesc', {
        autoplay:true,
            interval:5000,
            license:null,
            user:'54782917@N07',
            'set':'72157625444103928'
        });
   </script>


   <div class="theflickrshow" id="cesc">   
   </div>
    <script src="http://www.flickrshow.com/static/scripts/flickrshow-7.2.min.js"></script>
    <script>
        var cesc = new flickrshow('cesc', {
        autoplay:true,
            interval:5000,
            license:null,
            user:'54782917@N07',
            'set':'72157625443948800'
        });
    </script>
    <div class="flickrflash">
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="450" height="333" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F54782917%40N07%2Fsets%2F72157625443948800%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F54782917%40N07%2Fsets%2F72157625443948800%2F&amp;set_id=72157625443948800&amp;jump_to=" /><param name="allowFullScreen" value="true" /><param name="src" value="http://www.flickr.com/apps/slideshow/show.swf?v=71649" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="450" height="333" src="http://www.flickr.com/apps/slideshow/show.swf?v=71649" allowfullscreen="true" flashvars="offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F54782917%40N07%2Fsets%2F72157625443948800%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F54782917%40N07%2Fsets%2F72157625443948800%2F&amp;set_id=72157625443948800&amp;jump_to="></embed></object>
    </div>

You must not have the same ID more than once on the same page. 同一页上的ID不得超过一次。 Give the second <div> a differnt ID, adjust the Javascript below it accordingly and it should work. 给第二个<div>一个不同的ID,相应地调整它下面的Javascript,它应该可以工作。

You also don't need to include the flickrshow script more than once. 您也不需要多次包含flickrshow脚本。 It just needs to come first of all the Javascript. 它只需要首先使用Javascript。

<script src="http://www.flickrshow.com/static/scripts/flickrshow-7.2.min.js"></script>
<div class="theflickrshow" id="cesc">
   <p>Please enable Javascript to view this slideshow</p>
</div>


   <script>
        var cesc = new flickrshow('cesc', {
        autoplay:true,
            interval:5000,
            license:null,
            user:'54782917@N07',
            'set':'72157625444103928'
        });
   </script>


   <div class="theflickrshow" id="cesc2">   
   </div>
    <script>
        var cesc = new flickrshow('cesc2', {
        autoplay:true,
            interval:5000,
            license:null,
            user:'54782917@N07',
            'set':'72157625443948800'
        });
    </script>
    <div class="flickrflash">
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="450" height="333" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F54782917%40N07%2Fsets%2F72157625443948800%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F54782917%40N07%2Fsets%2F72157625443948800%2F&amp;set_id=72157625443948800&amp;jump_to=" /><param name="allowFullScreen" value="true" /><param name="src" value="http://www.flickr.com/apps/slideshow/show.swf?v=71649" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="450" height="333" src="http://www.flickr.com/apps/slideshow/show.swf?v=71649" allowfullscreen="true" flashvars="offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F54782917%40N07%2Fsets%2F72157625443948800%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F54782917%40N07%2Fsets%2F72157625443948800%2F&amp;set_id=72157625443948800&amp;jump_to="></embed></object>
    </div>

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

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