开发者

Javascript modal window code reconfigured to load on page load rather than onclick. Help :)

I have a js modal window which opens with an onclick function in a page on my site:

<a class="highslide" onclick="return hs.expand(this, { slideshowGroup: 'groupC0', wrapperClassName: 'wide-border', outlineType : 'rounded-white', dimmingOpacity: 0.8, align : 'center', transitions : ['expand', 'crossfade'], fadeInOut: true });" href="/images/phocagallery/thumbs/phoca_thumb_l_jen raymond_067 copy.jpg" title="jen raymond_067 copy">
<img alt="jen raymond_067 copy" src="/images/phocagallery/thumbs/phoca_thumb_m_jen raymond_067 copy.jpg">
</a>

I need this triggered as the page loads (not onclick, as above). I've been playing around with this js

<script type="text/javascript">
$(document).ready(开发者_运维知识库function() {
window.location.href = "/images/phocagallery/thumbs/phoca_thumb_l_jen raymond_067 copy.jpg";
});
</script>

But of course it only loads the image (href) - can you help include the class, title and onclick attributes to this js function - or is there a better way?

Please show me the light :)


You can try the following (keeping in mind I have no idea what this function does):

 $(document).ready(function(){

    hs.expand($('.highslide'), { 
         slideshowGroup: 'groupC0', 
         wrapperClassName: 'wide-border', 
         outlineType : 'rounded-white', 
         dimmingOpacity: 0.8, 
         align : 'center', 
         transitions : ['expand', 'crossfade'], fadeInOut: true });
    });

Thats the best I can come up with without looking up the hs(highlide?) api.


Try this:

$(function() {
    var yourAElement = $('.highslide')[0];
    hs.expand(yourAElement, { slideshowGroup: 'groupC0', wrapperClassName: 'wide-border', outlineType : 'rounded-white', dimmingOpacity: 0.8, align : 'center', transitions : ['expand', 'crossfade'], fadeInOut: true });
});


Thanks for the solutions above, maybe I'm just not knowledgable with JS, but I couldn't see my way using either, however I did get what I wanted using this method:

1) Add an ID to the Anchor tag

<a id="autoClick" class="highslide" onClick="return hs.expand(this, { slideshowGroup: 'groupC0', wrapperClassName: 'wide-border', outlineType : 'rounded-white', dimmingOpacity: 0.8, align : 'center', transitions : ['expand', 'crossfade'], fadeInOut: true });" href="/images/phocagallery/thumbs/phoca_thumb_l_jen raymond_067 copy.jpg" title="jen raymond_067 copy">
    <img alt="jen raymond_067 copy" src="/images/phocagallery/thumbs/phoca_thumb_m_jen raymond_067 copy.jpg">
</a>

2) Load JQuery if not already present

3) Add this function

$(document).ready(function() {
    $('#autoClick').click();
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜