Author Topic: Javascript, ist Null oder kein Objekt  (Read 9304 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.808
  • I ♥ 4I
    • View Profile
Javascript, ist Null oder kein Objekt
« on: June 26, 2008, 04:48:28 PM »
Hallo zusammen,

auf meiner Seite verwende ich folgendes "javascript- Tooltip"
Im Firefox (wie immer) geht alles reibungslos! Doch im IE 7 und IE Tab von Firefox gehen die ToolTips nicht, folgendes bekommt man zu Gesicht:



Zeile 155 wäre in der JS Datei:
Code: [Select]
toolTipSTYLE.top  = y + offsetY;
Ein Link wird so gesetzt:
Code: [Select]
<a href="#" onmouseover="toolTip('Du kannst 3 Fotos deiner Wahl und ein Video von dir hochladen!');" onmouseout="toolTip();" target="_blank" border="0">Fotos hochladen</a>
Dieser Code muss in der Datei vorhanden sein:
Code: [Select]
<!--
<div id="toolTipLayer" style="position: absolute; visibility: visible; display: none; left: 228px; top: 54px; width: 163px; height: 50px">
  <table bgcolor="#000000" border="0" cellpadding="0" cellspacing="1" width="160">
    <tbody>
      <tr>
        <td><table bgcolor="#ffffcc" border="0" cellpadding="5" cellspacing="0" height="100" width="160">
            <tbody>
              <tr>
                <td align="left">&nbsp;</td>
              </tr>
            </tbody>
          </table></td>
      </tr>
    </tbody>
  </table>
</div>
//-->
<b><font face="Arial, Verdana, Helvetica, sans-serif" size="1">
<script language="JavaScript" type="text/javascript">
<!--
initToolTips();
//-->
</script>

Das ist die JS Datei:
Code: [Select]
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
offsetX = 0;
offsetY = 20;
var toolTipSTYLE = "";

function initToolTips()
{
if (ns4 || ns6 || ie4 || ie55)
{
if (ns4)
{
toolTipSTYLE = document.toolTipLayer;
}
else if (ns6)
{
toolTipSTYLE = document.getElementById("toolTipLayer").style;
}
else if (ie4 || ie55)
{
toolTipSTYLE = document.all.toolTipLayer.style;
}

if (ns4)
{
document.captureEvents(Event.MOUSEMOVE);
}
else
{
toolTipSTYLE.visibility = "visible";
toolTipSTYLE.display = "none";
}
   
document.onmousemove = moveToMouseLoc;
}

//NaviHelperLeft = findPosX (document.getElementById('NavigationControl'));
}

function toolTipMove()
{
if (toolTipMove.arguments.length < 1)
{
document.onmousemove = "";
}
else
{
document.onmousemove = moveToMouseLoc;
}
}

function toolTip (msg, width, bg)
{
fg = "#000000";
//bg = "#FFFFCC";

if (!bg)
{
bg = "#FFFFFF";
}
if (bg == 0)
{
bg = "#FFFFFF";
}

if (toolTip.arguments.length < 1) // hide
{
if (ns4)
{
toolTipSTYLE.visibility = "hidden";
}
else
{
toolTipSTYLE.display = "none";
}
}
else // show
{
/*if (!fg)
{
fg = "#000000";
}
   
if (!bg)
{
bg = "#FFFFCC";
}*/

if (!width)
{
width = 170;
}
if (width == 0)
{
width = null;
}

var content =
'<table width="' + width + '" border="0" cellspacing="1" cellpadding="0" bgcolor="' + fg + '"><td>' +
'<table width="' + width + '" height="30" border="0" cellspacing="0" cellpadding="5" bgcolor="' + bg +
'"><td align="left"><span class="tooltip">' + msg +
'&nbsp\;</span></td></table></td></table>';

if (ns4)
{
toolTipSTYLE.document.write(content);
toolTipSTYLE.document.close();
toolTipSTYLE.visibility = "visible";
}
    else if (ns6)
{
document.getElementById("toolTipLayer").innerHTML = content;
toolTipSTYLE.display = 'block';
}
else if (ie4 || ie55)
{
document.all("toolTipLayer").innerHTML = content;
toolTipSTYLE.display = 'block';
}
else
{
document.all("toolTipLayer").innerHTML = content;
toolTipSTYLE.display = 'block';
}
}
}

function moveToMouseLoc(e)
{
if (ns4 || ns6)
{
x = e.pageX;

if ((x + 250) > window.screen.availWidth)
{
x = window.screen.availWidth - 240;
}

y = e.pageY;
}
else
{
x = event.x + document.body.scrollLeft;

if ((x + 250) > window.screen.availWidth)
{
x = window.screen.availWidth - 240;
}

y = event.y + document.body.scrollTop;
}

toolTipSTYLE.left = x + offsetX;
toolTipSTYLE.top  = y + offsetY;


//
// get left, top, width, height for active dropdown
//
/*if (ActiveDropDown)
{
var aleft   = ActiveDropDown.offsetLeft;
var awidth  = aleft + ActiveDropDown.offsetWidth;

if (ns4 || ns6)
{
var atop    = ActiveDropDown.offsetTop - 20; // 18
var aheight = atop + ActiveDropDown.offsetHeight + 20;

x = e.pageX;
y = e.pageY;
}
else
{
var atop    = ActiveDropDown.offsetTop - 18; // 16
var aheight = atop + ActiveDropDown.offsetHeight + 18;

x = event.x + document.body.scrollLeft;
y = event.y + document.body.scrollTop;
}

//
// Check if the mouse was moved outside the bound-area
//
if (!(x >= aleft && x <= awidth && y >= atop && y <= aheight) && !(x >= NaviHelperLeft && x >= (aleft - 25) && x <= awidth && y >= atop && y <= (atop + 18)))
{
ActiveDropDown.style.display = "none";

//
// Get id for the main navi item
//
id = ActiveDropDown.id.replace ("Div", "");

//
// Set background, color
//
if (document.getElementById(id).style.fontWeight == "normal" || document.getElementById(id).style.fontWeight == "")
{
document.getElementById(id).style.backgroundColor = "#7B7B7B";
document.getElementById(id).style.color   = "#CECECE";
}

//
// Show form elements / flash
//
if (DropDownExceptions != null)
{
for (i = 0; i < DropDownExceptions.length; i++)
{
document.getElementById(DropDownExceptions[i]).style.visibility = "visible";
}
}
}
}*/

return true;
}