【发布时间】:2014-04-19 17:37:21
【问题描述】:
背景:我为我目前正在开发的一个婚纱摄影网站购买了一个模板。我有一个关于 html 和 css 的平均知识库。从来没有真正做过 javascript,因为我大部分时间都花在编写 c# 上。您可以在
上查看该网站http://www.nm-photography.co.uk
可以在此处找到该网站的完整工作版本:http://themeforest.net/item/jphotolio-responsive-wedding-photography-template/full_screen_preview/3057579
错误:当您打开网站时,它可以正常工作并通过 javascript (jQuery(document)) 提取所有正确的图像。但是,如果您转到另一个页面,则在您按 ctrl r / f5 之前似乎没有加载任何 javascript。如果您返回主页,则除非您按刷新,否则这也不起作用。
我的研究:所以我花了几个小时在 Google 上进行挖掘,是的,甚至是第 2 页!有些人使用 on.load 函数,有些人使用一些后台工作函数?同样,我对 c# 有信心,而不是 javascript!我将粘贴下面的代码,前提是它不会太长!我不太确定在哪里放置正确的代码,所以如果有人能在正确的方向上帮助我,我将不胜感激:) 谢谢!
我还注意到,在 java 脚本中,右键单击已被禁用,但是,一旦刷新页面以加载图像,您就可以右键单击该页面。
<script type="text/javascript" src="js/jegbg.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($)
{
resize_window("#jegbgcontainer");
/** bind jeg default **/
$(window).jegdefault({
curtain : 1,
rightclick : 0,
clickmsg : "Disable Right Mouse Click"
});
var content = [
{ "index":0,
"type":"image",
"source":"images\/emr-1-3.jpg",
"pos":"top",
"title":"Image Slider",
"link":"masonry.html#!/gordon-jennas-wedding",
"desc":"<p><strong><\/strong>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.<\/p>\n<p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<\/p>\n"},
{"index":1,
"type":"image",
"source":"images\/misc-1-3.jpg",
"pos":"center",
"title":"Slider to contact",
"link":"contact.html",
"desc":"<p><strong><\/strong>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.<\/p>\n<p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<\/p>\n"},
{"index":2,
"type":"image",
"source":"images\/464713958_1d6a51c6c0_b1.jpg",
"pos":"top",
"title":"Slider to Password Page",
"link":"masonry.html#!/flower-peda",
"desc":"<p><strong><\/strong>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.<\/p>\n<p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<\/p>\n"},
{"index":3,
"type":"video",
"source":{ "videotype":"youtube",
"src":"http:\/\/www.youtube.com\/watch?v=w3jTxLs7Bek"},
"title":"Slider with Video",
"link":"masonry.html#!/just-married",
"desc":"<p><strong><\/strong>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.<\/p>\n<p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<\/p>\n"}
];
var holddesc = undefined;
var jegbg = $("#jegbgcontainer").jegbg({
fade_speed : 700,
delay : 10000,
content : content,
autostart : true,
partial_load : true
}, function(ele, media){
$('#homepita').fadeIn(1000);
$('#homepita .torapper').html(ele.title);
$(".homelink a").attr("href" , ele.link);
holddesc = ele.desc;
if(!$(".homeinfo").is(":visible")) {
pitaSlideUp();
}
});
/* binding touchwipe, disable this feature if using iphone */
if(scw(iphonewidth)) {
$(".texthome").touchwipe({
wipeLeft: function(e) {
jegbg.next();
return false;
},
wipeRight: function() {
jegbg.prev();
return false;
},
min_move_x: 20,
min_move_y: 20,
preventDefaultEvents: true
});
}
var pitaSlideUp = function(){
jegbg.restart();
$(".homeblock").slideUp("fast", function(){
$("#homepita").animate({
"right" : -288
}, function(){
$(".homeinfo").fadeIn("fast", function(){
$(this).attr("style","").addClass("displayblock");
});
$(".homeblock").removeClass("homedesc");
$(".homedescdetail").remove();
});
});
};
$(window).resize(function(){pitaSlideUp();});
var pitaSlideDown = function() {
jegbg.pause();
$("#homepita").addClass("hptoogle");
$(".homeblockinside").prepend("<div class='homedescdetail'>" + holddesc + "</div>");
$(".homeblock").slideDown("fast", function(){
$(this).addClass("homedesc");
$(".homedescdetail").css({
height : $('.homeblockinside').height() - 30,
width : $('.homeblockinside').width() - 12
});
jpanel = $(".homedescdetail").jScrollPane().data().jsp;
});
};
$(".homeinfo").click(function(){
$(this).fadeOut("fast");
$("#homepita").animate({
"right" : -5
}, function(){
pitaSlideDown();
});
});
$(".homeblock .closeme, .torapper").click(function(){
pitaSlideUp();
});
});
【问题讨论】:
-
尽量不要把 'JavaScript' 称为 'Java',这会让人困惑,让 JS 人愤怒
-
非常抱歉!我不知道有什么区别:/
-
你确定你正确地包含了 jquery,因为我的 chrome 开发者工具显示
Uncaught ReferenceError: jQuery is not defined并且没有图片来。 -
尝试使用谷歌CDN jquery
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> -
@Markus403 我试过了,但没用:/图像根本无法加载到网页上!
标签: javascript jquery html css refresh