Sziasztok!
Egy olyan kérdésem, lenne, hogy a lytebox nem akar működni a honlapomon.
A honlap felépítése:
index.php
Kód:
<?php
error_reporting(E_ALL & ~E_NOTICE);
header("Content-Type: text/html; charset=utf-8");
require_once("lib/head.class.php");
//require_once("lib/init.php");
session_start();
$_SESSION['url'] = $_SERVER['REQUEST_URI'];
require_once("header.php");
echo "<body>
<div align='center'>
<div id='container1' style='background: url(../images/backgrounds/bg.jpg);'>
<!-- Admin menü -->
<div id='admin'>
</div>
<!-- Főmenü -->
<div id='menu'>";
include_once("lib/menu.php");
echo " </div>
<!-- Tartalom -->
<div id='tartalom'>
</div>
<div class='loading' style='display: none; position: relative; top: 385px; left: -3px;' align='center'>
<img src='../images/loader.gif'>
</div>
</div>
</div>
</body>
</html>";
?>
A head.class.php, illetve a head.php hozzák létre a <head></head> részt.
A böngésző által kapott kód:
Kód:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
...
<link href="js/lytebox.css" rel="stylesheet" type="text/css" media="screen">
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/lytebox.js" type="text/javascript"></script>
...
</head>
A képfeltöltésnél van perpillanat probléma, amit ajax vezérel.
A form:
Kód:
...
$borderdata = "<script type='text/javascript' src='admin/scripts/ajaxupload.js'></script>
<div id='left_col'>
<fieldset>
<legend>Standard Use</legend>
<form action='/admin/scripts/ajaxupload.php?filename=name&maxW=800&fullPath=".$config['site']['url']."galeria/".$todo."/&relPath=../../galeria/".$todo."/&colorR=0&colorG=0&colorB=0&maxH=600&path=".$todo."/' method='post'>
<input type='file' name='name'>
<button onclick=\"ajaxUpload(this.form,'/admin/scripts/ajaxupload.php?filename=name&maxSize=9999999999&maxW=800&fullPath=".$config['site']['url']."galeria/".$todo."/&relPath=../../galeria/".$todo."/&colorR=0&colorG=0&colorB=0&maxH=600&path=".$todo."/','upload_area','Kép feltöltése folyamatban...<br /><img src=\'images/loader_light_blue.gif\' border=\'0\' />','<img src=\'images/error.gif\' border=\'0\' /> Error in Upload, check settings and path info in source code.'); return false;\" type='button' class='admin'>Kép feltöltése</button>
</form>
</fieldset>
</div>
<div id='upload_area' style='height: 150px;'></div>";
}
...
És a scriptek, amik vezérlik:
js:
Kód:
function $m(theVar){
return document.getElementById(theVar)
}
function remove(theVar){
var theParent = theVar.parentNode;
theParent.removeChild(theVar);
}
function addEvent(obj, evType, fn){
if(obj.addEventListener)
obj.addEventListener(evType, fn, true)
if(obj.attachEvent)
obj.attachEvent("on"+evType, fn)
}
function removeEvent(obj, type, fn){
if(obj.detachEvent){
obj.detachEvent('on'+type, fn);
}else{
obj.removeEventListener(type, fn, false);
}
}
function isWebKit(){
return RegExp(" AppleWebKit/").test(navigator.userAgent);
}
function ajaxUpload(form,url_action,id_element,html_show_loading,html_error_http){
var detectWebKit = isWebKit();
form = typeof(form)=="string"?$m(form):form;
var erro="";
if(form==null || typeof(form)=="undefined"){
erro += "The form of 1st parameter does not exists.\n";
}else if(form.nodeName.toLowerCase()!="form"){
erro += "The form of 1st parameter its not a form.\n";
}
if($m(id_element)==null){
erro += "The element of 3rd parameter does not exists.\n";
}
if(erro.length>0){
alert("Error in call ajaxUpload:\n" + erro);
return;
}
var iframe = document.createElement("iframe");
iframe.setAttribute("id","ajax-temp");
iframe.setAttribute("name","ajax-temp");
iframe.setAttribute("width","0");
iframe.setAttribute("height","0");
iframe.setAttribute("border","0");
iframe.setAttribute("style","width: 0; height: 0; border: none;");
form.parentNode.appendChild(iframe);
window.frames['ajax-temp'].name="ajax-temp";
var doUpload = function(){
removeEvent($m('ajax-temp'),"load", doUpload);
var cross = "javascript: ";
cross += "window.parent.$m('"+id_element+"').innerHTML = document.body.innerHTML; void(0);";
$m(id_element).innerHTML = html_error_http;
$m('ajax-temp').src = cross;
if(detectWebKit){
remove($m('ajax-temp'));
}else{
setTimeout(function(){ remove($m('ajax-temp'))}, 250);
}
}
addEvent($m('ajax-temp'),"load", doUpload);
form.setAttribute("target","ajax-temp");
form.setAttribute("action",url_action);
form.setAttribute("method","post");
form.setAttribute("enctype","multipart/form-data");
form.setAttribute("encoding","multipart/form-data");
form.submit();
if(html_show_loading.length > 0){
$m(id_element).innerHTML = html_show_loading;
}
}
php:
Kód:
...
<?php
if($imgUploaded){
echo "<img src='images/success.gif' border='0' style='marin-bottom: -4px;'> Sikeres feltöltés!<br><a href='galeria/images/".$upload_image."' rel='lytebox'><img src='galeria/images/thumb/thumb_".$upload_image."' border='0' width='128' height='128'></a>";
}else{
echo "<img src='images/error.gif' border='0' style='marin-bottom: -3px;' /> Hibás feltöltés: ";
foreach($errorList as $value){
echo $value.", ";
}
}
?>
Szépen feltöltődik a kép, megjelenik a thumb, viszont ha rákattintok, akkor a képet a főoldalon nyitja meg a lytebox használata nélkül....
Mi lehet a gond? (Az oldal betöltéseket mind ajax végzi)
Könyvjelzők