Expand|Select|Wrap|Line Numbers
- // tooltip.js
- function displayAlert()
- {
- alert("Test Alert!");
- }
[html]
<html>
<head>
<script src="tooltip.js"></script>
</head>
<body>
<a href="#" onmouseover='displayAlert()'>Test Link!</a>
</body>
</html>
[/html]
That does not work at all... In case you're wondering, the following is my code which I want to run...
Expand|Select|Wrap|Line Numbers
- // tooltip.js
- <!--
- var dom = ( document.getElementById ) ? true : false;
- var ns5 = ( !document.all && dom || window.opera ) ? true: false;
- var ie5 = ( (navigator.userAgent.indexOf( "MSIE" ) > -1 ) && dom) ? true : false;
- var ie4 = ( document.all && !dom) ? true : false;
- var nodyn = ( !ns5 && !ie4 && !ie5 && !dom ) ? true : false;
- var origWidth, origHeight;
- var tooltip, tipcss;
- var timeOutOne, timeOutTwo;
- var tipOn = false;
- var mouseX, mouseY;
- if (nodyn)
- {
- event = "nope"
- }
- function initTip()
- {
- document.write("initTip...")
- if (nodyn)
- return;
- tooltip = (ie4) ? document.all['tipDiv']: (ie5||ns5)? document.getElementById( 'tipDiv' ): null;
- tipcss = tooltip.style;
- if ( ie4 || ie5 || ns5)
- {
- tipcss.width = "160px";
- tipcss.fontFamily = "Verdana, arial, helvetica, sans-serif";
- tipcss.fontSize = "8pt";
- tipcss.color = "#000000";
- tipcss.backgroundColor = "#FF4400";
- tipcss.borderColor = "#000000";
- tipcss.borderWidth = "3px";
- tipcss.padding = "5px";
- tipcss.borderStyle = "ridge";
- }
- document.onmousemove = trackMouse;
- }
- window.onload = initTip;
- function displayAlert()
- {
- alert("Test Alert");
- }
- function doToolTip( eventObject, arrayDetails = "", background = "" )
- {
- // Array =>
- // [<number>] =>
- // ['Name'] = name of product
- // ['Price'] = price of product
- document.write("Doing the tool tip");
- if (!tooltip)
- return;
- if (timeOutOne)
- clearTimeout( timeOutOne );
- if (timeOutTwo)
- clearTimeout( timeOutTwo );
- tipOn = true;
- if (background)
- var curBgColor = "";
- else
- curBgColor = "#FF4400";
- if ( ie4 || ie5 || ns5 )
- {
- var message = '<table width="160px" style="font-family:Verdana, arial, helvetica, sans-serif; font-size:9px; color:#000000">';
- if (arrayDetails)
- {
- for (var i = 0; i < arrayDetails.length; i++)
- {
- message += '<tr><td valign="top">' + arrayDetails[i]["title"] + " - " + arrayDetails[i]["price"] + '</td></tr>';
- }
- }
- else
- {
- message += "N/A";
- }
- message += '</table>';
- tipcss.backgroundColor = curBgColor;
- tooltip.innerHTML = message;
- }
- //positionTip( eventObject );
- timeOutOne = setTimeout( "tipcss.visibility='visible'", 100);
- }
- function trackMouse( eventObject )
- {
- standardbody = ( document.compatMode == "CSS1Compat" )? document.documentElement : document.body
- mouseX = ( ns5 ) ? eventObject.pageX : window.event.clientX + standardbody.scrollLeft;
- mouseY = ( ns5 ) ? eventObject.pageY : window.event.clientY + standardbody.scrollTop;
- if ( tipOn )
- positionTip( eventObject );
- }
- function positionTip( eventObject )
- {
- var toolTipWidth = ( ie4 || ie5 ) ? tooltip.clientWidth: tooltip.offsetWidth;
- var toolTipHeight = ( ie4 || ie5 ) ? tooltip.clientHeight: tooltip.offsetHeight;
- var windowWidth = (ns5) ? window.innerWidth - 20 + window.pageXOffset : standardbody.clientWidth + standardbody.scrollLeft;
- var windowHeight = (ns5) ? window.innerHeight - 20 + window.pageYOffset : standardbody.clientHeight + standardbody.scrollTop;
- if ( ( mouseX -300 + toolTipWidth) > windowWidth )
- tipcss.left = mouseX - (toolTipWidth - 300) + "px";
- else
- tipcss.left = ( mouseX - 300 ) +"px";
- if ( ( mouseY + 300 + toolTipHeight ) > windowHeight )
- tipcss.top = ( windowHeight - ( toolTipHeight + 300 ) ) + "px";
- else
- tipcss.top = ( mouseY + 300 ) + "px";
- }
- function hideTip()
- {
- if (!tooltip)
- return;
- timeOutTwo = setTimeout( "tipcss.visibility='hidden'" , 100);
- tipOn = false;
- }
- document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')
- //-->
<?php
echo "<script language='javascript'>\n";
$totalProducts = 0;
$totalCost = 0.00;
if(isset($_COOKIE['basket']) )
{
$basketArray = $_COOKIE['basket'];
echo "var tempJavaArray = new Array();\n";
foreach ($basketArray as $key => $value)
{
++$totalProducts;
$array = getArrayDetails($value);
$price = (float)$array["price"];
echo "tempJavaArray[".($totalProducts -1)."][title] = ".$array["name"].";\n";
echo "tempJavaArray[".($totalProducts - 1)."][price] = ".sprintf("%.2f", $price).";\n";
$totalCost += price;
}
}
if ( $totalProducts )
{
$myString = sprintf("%s Items - £%.2f", $totalProducts, $totalCost);
echo "<a href='#' onmouseover='doToolTip(event)' onmouseout='hideTip()'>".$myString."</a>";
}
else
{
echo "<a href='#' title='Items: N/A'>0 Items - £0.00</a>";
}
echo "</script>\n";
?>
[/PHP]
And the webpage in question is http://stehartin.krpk.co.uk and the section is the basket section in the top right.
Thank you for your time, I hope someone can help me...
-freddukes