duanlang1531
2014-11-21 14:20
浏览 82

在哪里声明javascript / jQuery脚本

I'm trying to do some stuff with jquery/js (I don't know which one it is..), for example this script ; http://pastebin.com/V3HpU0NY - > http://blog.mainstreethost.com/light-youtube-embeds-faster-page-load#.VG9HKamkVSJ

But now comes the difficult part.

Url: http://erwin.my89.nl/stage/sieh/

enter image description here This is the website when you go to the url.

This loads the "gallery (top)" and all content/ and kinda images(lazyload) for all the 'gallery' posts. If this has to be done another way please say so.

When you click a image you'll get this: enter image description here

I hope you understand the idea.

So everything working ok

but now i go in to the inspector and i encounter this?!

enter image description here

I assume it is because i have the script defined in the loop of the content.. so when i click a gallery image, it loads another bunch of those text/css's.

So my question is: Is this the right way to do it? or should i be doing this different?

while ($loop->have_posts()) : $loop->the_post($post->ID);
 if ($metas) {
      foreach ($metas as $metakey) {

        } elseif ($metakey['url']) {
            preg_match(
                '/[\\?\\&]v=([^\\?\\&]+)/',
                $metakey['url'],
                $matches
            );
            $id = $matches[1];

            ?>
            <div class="youtube" id="<?php echo $id ?>" style="width: 560px; height: 315px;"></div>
            <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/youtube.js"></script>

        <?php

^part of the code, if need more please say so.

Thanks in advance!

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • drryyiuib43562604 2014-11-21 15:00

    Can you put your CSS file/s in the head? That's where it normally goes.

    Also, I don't see anywhere in your PHP where it could be loading these <style></style> tags. However it does look like it's going to import the same script at the end of each loop.

    Could you provide more information on what your exact problem is?

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题