Hi Ian,
most of the other guys here know what I am talking about because they
helped me to write the menu script.
I am not referring to errors occurring within the JS file. The script
is "perfectly" (ahah! ) fine. I am referring to the fact that if the JS
script is not present, MSIE gives a lot of errors.
Some other javascript command (onclick=") are also in the html file.
In any case, I append to this message the comple script and the
essential part of the HTML file. So you are able to get the whole
picture.
In any case thank for the "type" suggestion. I am going to change that.
Any kind of correction is very welcome (watch out for possible line
breaks).
HTML (I removed repetitions that are not necessary)
----------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<style type="text/css" media="screen">
..c7bg{position:absolute;background:#008000;border-width:1px;border-style
utset;}
..c7fg{position:absolute;border-width:0;color:#ffffff;background:transparent;text-align:center;font-family:Tahoma;font-size:11px;font-weight:bold;}
..c8bg{position:absolute;background:#228b22;border-width:1px;border-style
utset;}
..c8fg{position:absolute;border-width:0;color:#ffffff;background:transparent;text-align:center;font-family:Tahoma;font-size:11px;font-weight:bold;}
..menuItemStyle{
background:#ddeeff;border-width:1px;border-style:inset;font-family:Arial;font-size:11px
}
</style>
<script language="javascript" src="Ajax_Javascript.js"></script>
</head>
<body>
<div id ="RG1,0,0" class=c7bg enabledActions="4,6"
onclick="cellClick(event,this)" onmouseover = "mOver(this)" onmouseout
= "mOut(this)" style="top:170px;left:20px;width:89px;height:30px;">
<div class=c7fg style="top:7px;left:2px;"><table><tr><td width=83px
height=14px valign=middle>SHIPCOUNTRY</td></tr></table></div></div>
<div id ="RG1,0,1" class=c8bg enabledActions="4,2,6"
onclick="cellClick(event,this)" onmouseover = "mOver(this)" onmouseout
= "mOut(this)" style="top:170px;left:112px;width:89px;height:30px;">
<div
style="position:absolute;top:2253px;font-family:Tahoma;font-size:11px;font-weight:bold"><font
color="#c0c0c0">Report generated: <br>lunedì 25 settembre 2006
18.17.59</font><br><a href="
http://somesite/"><font
color="#c0c0c0">
http://somesite/</font></a><p></p></div>
<form name="form1" method="get" action="ReportProcessor.aspx">
<input type="hidden" name="hiddenFieldName" id="hiddenFieldID"/>
</form>
<div id="menuActions" style="position:absolute; display:none">
<table >
<tr>
<td bgcolor="#eeaa66" style="width: 15px"> </td>
<td id="menuItemContainer"></td>
</tr>
</table>
</div>
</body>
</html>
JS file
-----------------------------------------------------------------
// JScript File: Ajax_Javascript.js
//
http://groups.google.it/group/comp.lang.javascript/browse_frm/thread
/b3b8fa7bad9223a4?hl=it
//Laurent Bugnion, GalaSoft
function setStatus( strMessage )
{
// document.getElementById("statusInfo").firstChild.nodeValue =
strMessage;
}
var submitURL;
var oHttp = null;
function submitOnlyIfUrlActive() {
if ( window.XMLHttpRequest ) {
oHttp = new window.XMLHttpRequest();
}
else {
if (window.ActiveXObject ) {
oHttp = new window.ActiveXObject("Microsoft.XMLHTTP" );
}
else {
setStatus("Unsupported Platform");
}
}
if ( !oHttp ) {
setStatus("Error");
}
oHttp.onreadystatechange = submitOnlyIfUrlActiveCallback;
oHttp.open("HEAD", submitURL, true ); // true = async, false =
sync
setStatus( "Checking existence of report processor " + submitURL +
" ...");
oHttp.send( null );
}
function submitOnlyIfUrlActiveCallback() {
if ( oHttp.readyState == 4 ) {
if ( oHttp.status == 200 ) {
document.form1.submit();
}
else {
if (oHttp.status == 404) {
setStatus( submitURL + " Not Found");
}
else {
setStatus("Error: " + oHttp.status );
}
}
}
}
// JScript File: DynamicMenu.js
// onclick on the menuItem return coded info on the action
// and on the cell: MenuItem.id + "," + myCell.id
var menuActions;
var currentCell;
var mouseIsOnCellorMenu;
var previousStyle;
var UserActions=new Array();
UserActions[0]= "DRILL DOWN: include next dimension";
UserActions[1]= "DRILL DOWN this value" ;
UserActions[2]= "DRILL DOWN all values";
UserActions[3]= "DRILL DOWN parent value";
UserActions[4]= "ROLL UP: exclude next dimensions";
UserActions[5]= "ROLL UP this value";
UserActions[6]= "ROLL UP all values";
UserActions[7]= "ROLL UP parent value";
document.onmousedown = mMouseDownOnDoc;
function cellClick(event, myCell) {
currentCell = myCell;
if (myCell.id != null) {
var flags = myCell.getAttribute("enabledActions");
menuActions = document.getElementById("menuActions");
var actionCodes = flags.split(",")
var menuItemContainer =
document.getElementById("menuItemContainer");
menuItemContainer.innerHTML = "";
for ( var i = 0; i < actionCodes.length; i++ ) {
var actionCode = parseInt(actionCodes
)
menuItemContainer.innerHTML += "<div id=" + actionCodes
+
" class=menuItemStyle" +
" onmouseover='mOverMenuItem(this)'
onmouseout='mOut(this)' onclick='mClick(this)'>" +
"   " + UserActions[actionCode] + "
 </div>"
}
if (event == null) event = window.event;
var scrollTop = document.body.scrollTop ?
document.body.scrollTop : document.documentElement.scrollTop;
var scrollLeft = document.body.scrollLeft ?
document.body.scrollLeft : document.documentElement.scrollLeft;
menuActions.style.left = event.clientX + scrollLeft + 'px';
menuActions.style.top = event.clientY + scrollTop + 'px';
menuActions.style.display = 'block';
}
}
function mMouseDownOnDoc() {
if (!mouseIsOnCellorMenu) {
if (menuActions != null) {
menuActions.style.display = 'none';
}
}
}
function mOver(MyDiv) {
menuActions = document.getElementById("menuActions");
if (menuActions == null) {return} //in case page still
loading
mouseIsOnCellorMenu = true;
if (currentCell != MyDiv) {
menuActions.style.display = 'none';
currentCell = MyDiv;
}
if (previousStyle == null) {
previousStyle = MyDiv.style.backgroundColor;
MyDiv.style.backgroundColor = "#ffff00";
}
}
function mOverMenuItem(MyDiv) {
mouseIsOnCellorMenu = true;
if (previousStyle == null) {
previousStyle = MyDiv.style.backgroundColor;
MyDiv.style.backgroundColor = "#ffee22";
}
}
function mOut(MyDiv) {
mouseIsOnCellorMenu = false;
if (previousStyle != null) {
MyDiv.style.backgroundColor = previousStyle;
previousStyle = null;
}
}
function mClick(menuItem) {
alert("Clicked " + menuItem.id + "," + currentCell.id );
var hiddenField = document.getElementById("hiddenFieldID");
hiddenField.value = menuItem.id + "," + currentCell.id;
submitURL = document.form1.action;
submitOnlyIfUrlActive();
}
Ian Collins ha scritto: