[Javascript] disableselect in firefox
Troy III Ajnej
trojani2000 at hotmail.com
Thu Mar 2 18:01:45 CST 2006
Paul and Lee, thank's for your feedback.
Since we are moving outwards the problem because of Scotts joke with PDF,
I'll post the actual piece of my page I'm having problems with.
This is the "Picture Navigator" part of the "Picture Gallery Page".
This, of course, doesn't work in firefox. CSS alingn center doesn't work
also, only toggle expand/collapse does. While JavaScript Console is empty
and no errors are reported!
As you'll see, I've removed some brackets from the code for mailling
purpose.
This is my IE variant with some modifications for Firefox.
I have a seccond question: how does events buble in FX? Do they buble up or
down?
Why do they evaporate if not written in this manner?
Example:
function msefollower(e){ if(!e) e = window.event
navigator.style.posLeft= (e.screenX-dx)
navigator.style.posTop = (e.screenY-dy)
}
I remember having this issue with IE ver prior to 4.01, (a very long time
ago). The following version reports ' e (or) event undefined' in FX but
works since '98 in IE
The IE version:
function msefollower(){e = window.event
navigator.style.posLeft= (e.screenX-dx)
navigator.style.posTop = (e.screenY-dy)
}
Thank's in advance
THE CODE
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
html
head
style
IMG { height: 45px; border: 2px ridge #444499; background: white;
text-align: center; margin:1px}
#display { width:204; color: #7B8EBD; text-indent: 6; font: bold 8pt arial;
border: 2px solid #222233; background: black; text-align: center;
margin:1px}
#BASE { border-style:ridge; border-color:#63659C; width:200; height:150;
text-align: center; margin:1px}
INPUT,BUTTON { width: 98px; font: bold 8pt arial; text-align: center;
margin:1px}
#navigator { position: absolute; Top: 120px; Left: 10px; width:230px;
height:460px; text-align: center;margin:1px}
#navcapt { background: #202020; cursor: default; color: white; border: 1px
outset white; font:bold 8pt Arial; text-align: center; margin:1px}
#navbody { display:block; text-align: center;margin:1px}
/style
/head
<body style="color: #52B6DE; width: 100%; background: #0A0A0F">
<!--NAVIGATOR START-->
<DIV id="navigator">
<FIELDSET>
<LEGEND id="navcapt">  NAVIGATOR  </LEGEND>
<DIV id='navbody'>
<BUTTON id="load" Accesskey="L"><u>L</u>OAD </BUTTON><BUTTON id="galery"
Accesskey="G"><u>G</u>ALLERY</BUTTON><br />
<IMG ID="BASE" SRC="LOGO.JPG" width="200" height="150" /><br />
<BUTTON id="show" Accesskey="H"><u>H</u>IGH RES</BUTTON><BUTTON
id="save" Accesskey="S"><u>S</u>AVE</BUTTON><br />
<BUTTON id="moveleft"Accesskey=","><u><</u> MOVE </BUTTON><BUTTON
id="moveright" Accesskey="."> MOVE <u>></u></BUTTON>
</DIV>
<DIV ID="display">monitor</DIV>
</FIELDSET>
</DIV>
<!--NAVIGATOR END-->
/body
script
var dx, dy, mobile='false', dragged='false'
// vars added for W3C element refference compliance!
var navigator=document.getElementById("navigator")
var navcapt=document.getElementById("navcapt")
var nv=document.getElementById("navbody")
function expandcolapse(){
if(dragged=='false'){
if(nv.style.display!="none"){nv.style.display='none'}else{nv.style.display='block'}
}
}
function enablemove(event){ if(!event) event = window.event //suppressing
'event not defined' in firefox
mobile='true';
dragged='false'; //revive toggle navigator
dx=event.screenX-navigator.offsetLeft // (a-b) always >= 0
dy=event.screenY-navigator.offsetTop
}
function disablemove(){mobile='false'}
function mousefollower(event){ if(!event) event = window.event //suppressing
'event not defined' in firefox
if(mobile=='true'){
navigator.style.posLeft= (event.screenX-dx) // IE supports "event.x"
over "event.clientX" and "screenX" also.
navigator.style.posTop = (event.screenY-dy) }
}
function canceldefault(){dragged='true'; return false}
navigator.onmousedown=enablemove
document.onmousemove=mousefollower //prevent mouse escaping from draged-el
navigator.onmouseup=disablemove
navigator.onselectstart=canceldefault //disable select
navigator.ondragstart = canceldefault //disable image drag
navcapt.onclick = expandcolapse
/script
/html
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Troy III
progressive art enterprise
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
More information about the Javascript
mailing list