Witam,
Od wczoraj męczę się ze starym już skryptem, który ma za zadanie blokadę prawego klawisza myszy, a zamiast tego wyświetlenie własnego menu.
Oczywiście testowałem inne skrypty, lecz wszystkie działają tylko w obrębie stopki lub ogłoszenia.
<style type="text/css"> .skin0 { BORDER-RIGHT: #cdcac8 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 11px; Z-INDEX: 100; VISIBILITY: hidden; BORDER-LEFT: #ffffff 1px solid; WIDTH: 150px; LINE-HEIGHT: 14px; BORDER-BOTTOM: #a4a3a3 1px solid; FONT-FAMILY: Arial; POSITION: absolute; BACKGROUND-COLOR: #ede9e3 } .menuitems { PADDING-RIGHT: 5px; PADDING-LEFT: 5px; CURSOR: hand; } .titlemedium2 { PADDING-RIGHT: 0px; PADDING-LEFT: 1px; FONT-WEIGHT: bold; FONT-SIZE: 11px; BACKGROUND-IMAGE: url(m_bar.gif); PADDING-BOTTOM: 1px; COLOR: #cccccc; LINE-HEIGHT: 150%; PADDING-TOP: 1px; FONT-FAMILY: Arial, Helvetica, sans-serif; HEIGHT: 19px; } </style> <DIV class="skin0" id="ie5menu" onmouseover="highlightie5(event)" onclick="jumptoie5(event)" onmouseout="lowlightie5(event)"> <DIV class=titlemedium2><B> Szybkie menu</B></DIV> <DIV class="menuitems" target="_blank" url="http://www.earth2140.pun.pl">Forum</DIV> <DIV class=menuitems target="_top" url="http://www.earth2140.pun.pl/search.php">Szukaj</DIV> <DIV class=menuitems url="http://onet.pl"><img src="http://earth2140.ffox.pl/grafika/posty/$przyklejony.png"></DIV> </DIV> <SCRIPT language=JavaScript1.2> //set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar var display_url=1 var ie5=document.all&&document.getElementById var ns6=document.getElementById&&!document.all if (ie5||ns6) var menuobj=document.getElementById("ie5menu") function showmenuie5(e){ //Find out how close the mouse is to the corner of the window var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY //if the horizontal distance isn't enough to accomodate the width of the context menu if (rightedge<menuobj.offsetWidth) //move the horizontal position of the menu to the left by it's width menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth else //position the horizontal position of the menu where the mouse was clicked menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX //same concept with the vertical position if (bottomedge<menuobj.offsetHeight) menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight else menuobj.style.top=ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY menuobj.style.visibility="visible" return false } function hidemenuie5(e){ menuobj.style.visibility="hidden" } function highlightie5(e){ var firingobj=ie5? event.srcElement : e.target if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){ if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node firingobj.style.backgroundColor="#6B6F7B" firingobj.style.color="#FFFFFF" if (display_url==1) window.status=event.srcElement.url } } function lowlightie5(e){ var firingobj=ie5? event.srcElement : e.target if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){ if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node firingobj.style.backgroundColor="#EDE9E3" firingobj.style.color="" window.status='' } } function jumptoie5(e){ var firingobj=ie5? event.srcElement : e.target if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){ if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode if (firingobj.getAttribute("target")) window.open(firingobj.getAttribute("url"),firingobj.getAttribute("target")) else window.location=firingobj.getAttribute("url") } } if (ie5||ns6){ menuobj.style.display='' document.oncontextmenu=showmenuie5 document.onclick=hidemenuie5 } </SCRIPT>
Generalnie wszystko działa.
Klikam prawym klawiszem myszy i pojawia się owe menu.
Natomiast na forum wykrzacza się przez Doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Przez to, moje menu pojawia się w górnym lewym rogu, a nie tam gdzie kliknę myszą.
Wystarczy że w Doctype byłaby możliwość zmiany z html PUBLIC na jakąkolwiek inną, np. xhtml PUBLIC i wszystko by działało.
Niestety nie mam sposobu żeby to zmienić.
Skrypt jest już dosyć stary, ale działa na wszystkich przeglądarkach.
Zechciałbyś zerknąć na niego?
Offline
Nie wiem w czym leży rzecz aczkolwiek samo zrobienie tego pod prawym klawiszem jest złym wyjściem >.< nawet do źródła się dostać nie mogłem by zobaczyć o co chodzi. Nie wspomnę o odświeżaniu. Na początek to zamieniłbym "DIV" na "div" i każdą klasę umieszczał w "klasa"... w twoich przypadku wygląda to tak:
<DIV class=menuitems targ ...........
Offline
Witam,
No właśnie celem skryptu jest utrudnienie ludziom zaglądania do źródła.
Wyeliminować się tego nie da, bo jak ktoś będzie bardzo chciał i tak zajrzy.
Drugim zadaniem tego skryptu byłoby wygodne poruszanie się po menu strony/forum.
Pod prawym klawiszem byłyby najważniejsze funkcje takie jak Szukaj, itp.
Co do klas, jest to stary skrypt w wersji 1.2, ale mimo że archaiczny to teoretycznie działa (np na IE9).
Zaktualizuje wszystkie klasy, zobaczymy co z tego wyjdzie.
EDIT:
Niestety poprawa nie pomogła :-(
Ostatnio edytowany przez ffox (2011-12-06 22:29:30)
Offline