Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / September 2004

Tip: Looking for answers? Try searching our database.

javascript error  in mozilla

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
falling_star - 20 Sep 2004 11:14 GMT
the code below run correctly in IE, but the float menu didn't display in
mozilla explorer, what is the trouble?
menu.htm:

<script language="javascript">
document.writeln("     <DIV id=menuDiv style=\"Z-INDEX: 2; VISIBILITY:
hidden; WIDTH: 50px; POSITION: absolute; HEIGHT: 1px; BACKGROUND-COLOR:
#ffffff\"></DIV>");

//????????????????
var h;
var w;
var l;
var t;
var topMar = 1;
var leftMar = -2;
var space = 1;
var isvisible;
var MENU_SHADOW_COLOR='#ffffff';//??????????????????
var global = window.document
global.fo_currentMenu = null
global.fo_shadows = new Array

function HideMenu()
{
var mX;
var mY;
var vDiv;
var mDiv;
if (isvisible == true)
{
 vDiv = document.all("menuDiv");
 mX = window.event.clientX + document.body.scrollLeft;
 mY = window.event.clientY + document.body.scrollTop;
 if ((mX < parseInt(vDiv.style.left)) || (mX >
parseInt(vDiv.style.left)+vDiv.offsetWidth) || (mY <
parseInt(vDiv.style.top)-h) || (mY >
parseInt(vDiv.style.top)+vDiv.offsetHeight)){
  vDiv.style.visibility = "hidden";
  isvisible = false;
 }
}
}

function ShowMenu(vMnuCode,tWidth) {
     var e  = window.event ;
  var vSrc = e.target || e.srcElement;
//  var vSrc=e.target?e.target:e.srcElement;

 vMnuCode = "<table border=0 id='menu' cellspacing=1 cellpadding=3
style='width:"+tWidth+"' class=MenuDropDown onmouseout='HideMenu()'><tr
height=23><td nowrap align=left class=MenuDropDown>" + vMnuCode +
"</td></tr></table>";

h = vSrc.offsetHeight;
w = vSrc.offsetWidth;
l = vSrc.offsetLeft + leftMar+4;
t = vSrc.offsetTop + topMar + h + space-2;

vParent = vSrc.offsetParent;

while (vParent.tagName.toUpperCase() != "BODY")
{

 l += vParent.offsetLeft;
 t += vParent.offsetTop;
 vParent = vParent.offsetParent;
}

menuDiv.innerHTML = vMnuCode;
menuDiv.style.top = t;
menuDiv.style.left = l;
menuDiv.style.visibility = "visible";
isvisible = true;

}

s4='<a href=#>open</a><br>';
s4+=' <a href=#> save</a> <br>';
s4+='<a href=#>close</a><br>';
s4+='<a href=#>close all</a><br>';
s4+='<a href=#>exit</a><br>';

</script>
<table>
 <tr>
 <td>
 <a href="#"
 onmouseover ="javascript:ShowMenu(s4,80)"
 onmouseout="HideMenu()" > File
 </a></td>
</tr></table
Steve Fulton - 20 Sep 2004 14:12 GMT
> the code below run correctly in IE, but the float menu didn't display in
> mozilla explorer, what is the trouble?

[snip]

>   vDiv = document.all("menuDiv");
>   mX = window.event.clientX + document.body.scrollLeft;

[snip]

You're using MS-proprietary code.

document.all is an IE-ism, not supported by other clients. Fortunately,
IE supports the standards-compliant getElementById method.

  document.getElementById("menuDiv")

window.event is also an IE-ism. Unfortunately, IE does not support
passing the event to the handler as an argument, as other clients do.
You have to tapdance around this shortcoming.

  var evt = window.event || arguments[0];

You'll also have to be aware that IE implements proprietary methods and
properties of the Event object. Consult the DOM-2 Events spec
<URL:http://www.w3.org/TR/DOM-Level-2-Events/> for standards
information and the Mozilla DOM Events documentation
<URL:http://www.mozilla.org/docs/dom/domref/dom_event_ref.html> for
information about its implementation of the standard.

Signature

Steve

Popularity is the crown of laurel which the world puts on bad art.
Whatever is popular is wrong. -Oscar Wilde


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.