简体   繁体   English

无法加载资源错误

[英]Failed To Load Resource Error

I am having trouble viewing 3 different background-image .jpg files through one thumbnailFilePath in javascript. 我无法通过javascript中的一个thumbnailFilePath查看3个不同的背景图像.jpg文件。 The HTML and CSS coding does recognize all of the files correctly, but the background images will not load into a browser. HTML和CSS编码可以正确识别所有文件,但是背景图像不会加载到浏览器中。 Therefore, you can not view these images. 因此,您无法查看这些图像。 On the other hand, the browser does recognize to see the javascript videocaption text and the play_icon.png image files correctly. 另一方面,浏览器确实识别出可以正确看到javascript videocaption文本和play_icon.png图像文件。

// JavaScript Document
$(document).ready(function(){

  $('a.videoLink').each(function(){ 

    var thumbnailFilePath = 'video/'+$(this).attr('videofile')+'.jpg';
    var videoCaption = $(this).attr('videocaption');

    $(this).css('background-image','url('+thumbnailFilePath+')'); 
    $(this).html('<div class="caption">'+videoCaption+'</div><img src="../images/play_icon.png" class="play"/>');

  });

});

Maybe your video directory is not located in the same directory like your javascript file with this code? 也许您的视频目录与使用此代码的javascript文件不在同一个目录中? Otherwise use a additional slash in front of "video", if it is in the root: 否则,如果在根目录中,则在“视频”前面使用一个额外的斜杠:

var thumbnailFilePath = '/video/'+$(this).attr('videofile')+'.jpg';

What's the value of the following attribute? 以下属性的值是什么?

.attr('videofile')

Did you give attention to the file extension? 您是否关注文件扩展名? (maybe result is: myvideofile.mpg.jpg) (结果可能是:myvideofile.mpg.jpg)

The answer is that my .jpg files must have the identical file name as my HTML source code. 答案是我的.jpg文件必须与HTML源代码具有相同的文件名。 The videofile="bruce_waltke" must have the same .jpg name. videofile =“ bruce_waltke”必须具有相同的.jpg名称。 So my .jpg file was named bruce waltke.jpg with no underscore in-between. 因此我的.jpg文件被命名为bruce waltke.jpg,中间没有下划线。 So the .jpg was initially saved as bruce waltke.jpg but it is now saved as bruce_waltke.jpg....So the image file was broken but its now fixed. 因此,.jpg最初保存为bruce waltke.jpg,但现在又保存为bruce_waltke.jpg ....因此,图像文件已损坏,但现在已修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM