Hi,
nachdem ich eine "Drag & Drop" Funktion eingebaut habe, funktionieren meine Links im NN nicht mehr.
Liegt wohl daran, daß ich 'onmousedown' für 'startDrag' verwende.
Kann mir bitte jemad einen Tipp geben, wie ich das anders machen könnte.
Danke und sorry, daß ich ständig mit dieser DHTML Geschichte nerve.
http://www.floridee.de/Schieberegler_horizontal_NN2.htm
Der Code:
<html>
<head>
<title>Test</title>
<SCRIPT language=JavaScript type=text/javascript>
<!--
var position;
var xBg;
var yBg;
function init()
{
xBg = findPos(document.sliderBg).xPos;
yBg = findPos(document.sliderBg).yPos;
NN= document.layers ? true : false;
IE= document.all ? true : false;
if (NN)
{
document.layers[0].left = xBg+110;
document.layers[0].top = yBg+10;
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
}
if (IE)
{
document.all.slider.style.left = xBg+110;
document.all.slider.style.top = yBg+10;
}
document.onmousedown = startDrag;
document.onmouseup = endDrag;
}
function startDrag(e)
{
var found = false;
if (NN)
{
var gefunden = 0;
var obj = document.layers[0];
if ((e.pageX > obj.left) && (e.pageX < obj.left + obj.clip.width) && (e.pageY > obj.top) && (e.pageY < obj.top + obj.clip.height)) gefunden = true;
if (gefunden)
{
current = document.layers[0];
dx = e.pageX - current.left;
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = drag;
return false;
}
}
if (IE)
{
var obj = window.event.srcElement;
if (obj.parentElement.id.indexOf("slider") != -1)
{
current = obj.parentElement.style;
dx = window.event.clientX - current.pixelLeft;
document.onmousemove = drag;
return false;
}
}
current = null;
return false;
}
function drag(e)
{
if (current != null)
{
var max = 217 + xBg;
var min = 5 + xBg;
if (NN)
{
current.left = e.pageX - dx;
if (current.left<min) current.left=min;
if (current.left>max) current.left=max;
var position=Math.round((current.left-min)/((max-min)/12));
document.form1.test.value = position;
}
if (IE)
{
current.pixelLeft = window.event.clientX - dx;
if (current.pixelLeft<min) current.pixelLeft=min;
if (current.pixelLeft>max) current.pixelLeft=max;
var position=Math.round((current.pixelLeft-min)/((max-min)/12));
document.form1.test.value = position;
}
}
return false;
}
function endDrag(e)
{
if (NN) document.releaseEvents(Event.MOUSEMOVE);
document.onmousemove = null;
current = null;
return false;
}
function findPos(el)
{
var xPos = 0;
var yPos = 0;
if(document.layers)
{
xPos = el.x;
yPos = el.y;
}else
{
while(el)
{
xPos += el.offsetLeft;
yPos += el.offsetTop;
el = el.offsetParent;
}
}
return {xPos: xPos, yPos: yPos};
}
// -->
</script>
</head>
<body onload="init()">
<div id="slider" style="POSITION: absolute;">
<layer>
<img border="0" src="images/reiterlein/regler2.gif" width="30" height="25">
</layer>
</div>
<table border="1" cellpadding="0" cellspacing="0" width="250">
<tr>
<td align="center">
<p><a href="http://www.teamone.de/selfaktuell/forum/">link</a></p>
</td>
</tr>
<tr>
<td align="center">
<p><form name="form1"><input type="text" name="test" size="10"></form></p>
</td>
</tr>
<tr>
<td align="center">
<p><img border="0" src="images/reiterlein/regler1.gif" name="sliderBg" width="250" height="40"></p>
</td>
</tr>
</table>
</body>
</html>