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?

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建