사용자가 탐색 메뉴에서 "CONTACT"를 클릭하면 멋진 상자 팝업을 열려고합니다. JSFiddle에서 작동하지만 http://jsfiddle.net/88X6D/1/을 참조하십시오. 그러나 라이브 환경에서는 작동하지 않습니다. http://goo.gl/lkfxeO을 참조하십시오. (메뉴에서 "연락처"를 클릭해도 아무런 변화가 없습니다)Fancybox 열기 문제 - JSFiddle에서 작동하지만 라이브 환경에서는 작동하지 않습니다.
처음에는 "부드럽게 스크롤 "스크립트와"문의 양식 "스크립트가 있지만 JSfiddle에서 작동하므로이 문제는 다른 곳에서 발생해야합니다. (또한 fancybox JS 파일과 jquery가 올바르게 호출 됨). 당신의 도움이
HTML
<li> <a href="#inline" class="modalbox highlightit">Contact</a>
</li>
스크립트
감사합니다 (이 파일에 있습니다 : JS/scripts.js)
//==============
//! Smooth scrolling
//==============
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 100
}, 'normal');
return false;
}
}
});
})
window.onscroll = scrollFunction;
function scrollFunction() {
var doc = document.documentElement, body = document.body;
var top = (doc && doc.scrollTop || body && body.scrollTop || 0);
if (top > 200) {
$('.back-to-top').fadeIn();
}
else {
$('.back-to-top').fadeOut();
}
}
//==============
//! Contact form
//==============
function validateEmail(email) {
var reg = /^(([^<>()[\]\\.,;:\[email protected]\"]+(\.[^<>()[\]\\.,;:\[email protected]\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return reg.test(email);
}
$(document).ready(function() {
$(".modalbox").fancybox();
$("#contact").submit(function() { return false; });
$("#send").on("click", function(){
var emailval = $("#email").val();
var msgval = $("#msg").val();
var msglen = msgval.length;
var mailvalid = validateEmail(emailval);
var nameval = $("#name").val();
if(mailvalid == false) {
$("#email").addClass("error");
}
else if(mailvalid == true){
$("#email").removeClass("error");
}
if(msglen < 4) {
$("#msg").addClass("error");
}
else if(msglen >= 4){
$("#msg").removeClass("error");
}
if(nameval < 2) {
//name must be at least 2 characters
$("#name").addClass("error");
}
else if(nameval >= 2){
$("#name").removeClass("error");
}
if(mailvalid == true && msglen >= 4) {
// if both validate we attempt to send the e-mail
// first we hide the submit btn so the user doesnt click twice
$("#send").replaceWith("<em>sending...</em>");
$.ajax({
type: 'POST',
url: '../sendmessage.php',
data: $("#contact").serialize(),
success: function(data) {
if(data == "true") {
$("#contact").fadeOut("fast", function(){
$(this).before("<p><strong>Success! Your message has been sent, thank you.</strong></p>");
setTimeout("$.fancybox.close()", 1000);
});
}
}
});
}
});
});
을 (HTTP ://fancybox.net/howto))? –
귀하의 의견을 보내 주셔서 감사합니다. 귀하의 링크가 구식 상자의 구버전을 의미한다고 생각합니다. 어쨌든, 성공을 거두지 않고이 헤더를 성공에 추가했습니다. – Greg
당신은 결국 당신의 소스에 그 라인이 있다는 것을 알 수있다. 그것은 'contact form'섹션의'$ (document) .ready() 호출에있다. 선택자로'.fancybox' 대신에'.modalbox'를 사용해야합니다. 링크 이름이기 때문입니다. 나는 새로운 문서가 [여기] (http://fancyapps.com/fancybox/#instructions)라고 생각한다. –