Javascript 模式窗口代码重新配置为在页面加载时加载而不是在单击时加载。帮助 :)

发布于 2024-11-05 05:34:44 字数 894 浏览 4 评论 0原文

我有一个 js 模式窗口,它在我网站的页面中通过 onclick 函数打开:

<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>

我需要在页面加载时触发此窗口(不是 onclick,如上所述)。我一直在玩这个js,

<script type="text/javascript">
$(document).ready(function() {
window.location.href = "/images/phocagallery/thumbs/phoca_thumb_l_jen raymond_067 copy.jpg";
});
</script>

但当然它只加载图像(href) - 你能帮助将类、标题和onclick属性包含到这个js函数中 - 或者有更好的方法吗?

请让我看到光:)

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 :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时光与爱终年不遇 2024-11-12 05:34:44

您可以尝试以下操作(请记住,我不知道这个函数的作用):

 $(document).ready(function(){

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

这是我在不查找 hs(highlide?) api 的情况下能想到的最好的方法。

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.

眼藏柔 2024-11-12 05:34:44

试试这个:

$(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 });
});

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 });
});
赠佳期 2024-11-12 05:34:44

感谢上面的解决方案,也许我只是不了解JS,但我看不到我的使用方式,但是我确实使用这种方法得到了我想要的:

1)向锚标记添加ID

<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)加载JQuery 如果尚不存在

3) 添加此函数

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

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();
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文