Hallo,
ich hatte vor in ein vorhandenes script eine "if" Abfrage einzubauen, die sich auf die Browserweite bezieht.
Das hat auch in Firefox und Opera geklappt nur der IE spielt nicht mit.
Der IE nimmt bei den bildern immer die breite von "863px" bzw. "385px".
Hier der Code:
////////////////////////////////////////////////////////////////////////////////
// GLOBAL VARS
var imgs;
var imgsGallery = new Array();
////////////////////////////////////////////////////////////////////////////////
// MOUSE EVENTS
function setOnMouseClick() {
var elements = document.getElementsByTagName("a");
for (var i = 0; i < elements.length; i++) {
switch(elements[i].className) {
case "next":
elements[i].onclick = function() {
imgs.move('next');
return false;
}
break;
case "prev":
elements[i].onclick = function() {
imgs.move('prev');
return false;
}
break;
}
}
}
////////////////////////////////////////////////////////////////////////////////
// INIT
if (navigator.appName == "Microsoft Internet Explorer" || screen.width <= 1280) {function init() {
setOnMouseClick();
// images gallery
imgsGallery[0] = new Object();
imgsGallery[0].image = new Image(width="590");
imgsGallery[0].image.src = "images/hochzeit1/1.jpg";
imgsGallery[0].title = "Hochzeit I";
imgsGallery[0].caption = "1/3";
imgsGallery[1] = new Object();
imgsGallery[1].image = new Image(width="263");
imgsGallery[1].image.src = "images/hochzeit1/2.jpg";
imgsGallery[1].title = "Hochzeit I";
imgsGallery[1].caption = "2/3";
imgsGallery[2] = new Object();
imgsGallery[2].image = new Image(width="590");
imgsGallery[2].image.src = "images/hochzeit1/3.jpg";
imgsGallery[2].title = "Hochzeit I";
imgsGallery[2].caption = "3/3";
// MudShiftContent(id, unitX, unitTotal)
imgs = new MudShiftContent('imgs', imgsGallery);
// set init
if ($('imgs_title')) $('imgs_title').innerHTML = imgsGallery[0].title;
if ($('imgs_caption')) $('imgs_caption').innerHTML = imgsGallery[0].caption;
}
}
if (screen.width > 1280) {function init() {
setOnMouseClick();
// images gallery
imgsGallery[0] = new Object();
imgsGallery[0].image = new Image(width="863");
imgsGallery[0].image.src = "images/hochzeit1/1.jpg";
imgsGallery[0].title = "Hochzeit I";
imgsGallery[0].caption = "1/3";
imgsGallery[1] = new Object();
imgsGallery[1].image = new Image(width="385");
imgsGallery[1].image.src = "images/hochzeit1/2.jpg";
imgsGallery[1].title = "Hochzeit I";
imgsGallery[1].caption = "2/3";
imgsGallery[2] = new Object();
imgsGallery[2].image = new Image(width="863");
imgsGallery[2].image.src = "images/hochzeit1/3.jpg";
imgsGallery[2].title = "Hochzeit I";
imgsGallery[2].caption = "3/3";
// MudShiftContent(id, unitX, unitTotal)
imgs = new MudShiftContent('imgs', imgsGallery);
// set init
if ($('imgs_title')) $('imgs_title').innerHTML = imgsGallery[0].title;
if ($('imgs_caption')) $('imgs_caption').innerHTML = imgsGallery[0].caption;
}
}
////////////////////////////////////////////////////////////////////////////////
// EVENTS
Event.observe(window, 'load', init, false);
Ende des Codes
Da der IE die "width" nicht erkannt hat, habe ich noch "navigator.appName" hinzugefügt, das hat aber auch nichts gebracht.
Wäre toll wenn mir jemand weiterhelfen könnte. Danke schon mal!