Jump to content

Recommended Posts

Posted

I've been working on this web page

but run into a problem with the javascript code for browsers other than I.E.

The page has popups which contain the data for the planet or system under the mouse pointer

(I've still to add the data for the Flux fields)

I normally just ignore the other browsers and cater only for Explorer but I thought I'd have a go at it.

Armed with Goggle and some good reference sites I attempted to modify my code

but I just cant get it to work for the others browsers.

Here is the javascript code (for the full page code just use view source from the above link)

code:

<SCRIPT TYPE="TEXT/JAVASCRIPT" LANGUAGE=JAVASCRIPT>

<!-- Hide script from older browsers

var browser = "";

//detecting older netscapes

if (!document.all){browser = "Old Netscape"}

//detecting Opera

if (navigator.userAgent.indexOf("Opera") > 0){browser = "Opera"}

//detecting IE

if (navigator.appName =="Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") < 0){browser = "IE"}

//detecting newer Netscapes

if (navigator.appName == "Netscape" && document.all && navigator.userAgent.indexOf("Opera") < 0){browser = "Newer Netscape"}

if (document.getElementById)

{

docObj = "document.getElementById('"

styleObj = "').style"

}

else

{

docObj = "document."

styleObj = ""

}

function popUp(evt,currElem)

{

// document.getElementById('popUpxx').style or document.popUpxx

popUpWin = eval(docObj + currElem + styleObj)

if (browser == "IE")

{

// document.getElementById('popUpxx').style

popUpWin.top = parseInt(evt.y)+2 + document.body.scrollTop

popUpWin.left = (Math.max(2,parseInt(evt.x)-250) + document.body.scrollLeft)

}

else if (browser == "Newer Netscape")

{

// document.getElementById('popUpxx').style

popUpWin.top = parseInt(evt.pageY)+2 + window.pageYOffset

popUpWin.left = (Math.max(2,parseInt(evt.pageX)-250) + window.pageXOffset)

}

else

{

// document.popUpxx

popUpWin.top = parseInt(evt.pageY)+2 + window.pageYOffset

popUpWin.left = (Math.max(2,parseInt(evt.pageX)-250) + window.pageXOffset)

}

popUpWin.visibility = "visible"

window.status = ""

}

function popDown(currElem)

{

popUpWin = eval(docObj + currElem + styleObj)

popUpWin.visibility = "hidden"

}

// End hiding script -->

</SCRIPT>

The code is still a little rough as I'm not taking into account the varying popup sizes,

but hey when you scroll the screen the popups pop in the right place

and if you are to close to the left the don't roll off the screen

any help would be appreciated.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...