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

在哪里声明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?

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站