Hej
Jag vill ändra en mouseovereffekt
med detta men det funkar inte
klistrain.onmouseover="this.style.background='#0A246A'; this.style.color='#ffffff'" onmouseout="this.style.background='#D4D0C8'; this.
13 svar · 267 visningar · startad av Addeladde
Hej
Jag vill ändra en mouseovereffekt
med detta men det funkar inte
klistrain.onmouseover="this.style.background='#0A246A'; this.style.color='#ffffff'" onmouseout="this.style.background='#D4D0C8'; this.
onmouseover="this.style.background='#0A246A'; this.style.color='#ffffff'"
vad är klistrain.onmouseover ? testa att sätta , tecken mellan funktionerna
Så här ser hela sidan ut:
function contextMeny() {
if (clipboardData.getData("Text") == null) {
klistrain.disabled = true;
klistrain.onmouseover='';
}
else {
klistrain.style.disabled = false;
klistrain.onmouseover="this.style.background='#0A246A', this.style.color='#ffffff'";
}
markerattxt = document.selection.createRange().text;
if (markerattxt != '') {
klipput.disabled = true;
}else{
klipput.disabled = false;
}
}
</script>
<div width="108" style="background='#D4D0C8'; border-right: 1px solid #404040; border-left: 1px solid #D4D0C8; border-top: 1px solid #D4D0C8; border-bottom: 1px solid #404040;">
<div width="108" style="background='#D4D0C8'; border-right: 1px solid #808080; border-left: 1px solid #ffffff; border-top: 1px solid #ffffff; border-bottom: 1px solid #808080;">
<table cellspacing="4" width="108">
<div id="klippUtLager" name="klippUtLager" height="20" width="108" onClick="doCut()" onmouseover="this.style.background='#0A246A'; this.style.color='#ffffff';" onmouseout="this.style.background='#D4D0C8'; this.style.color='#000000'" style="background='#D4D0C8'; cursor: default;">
<span id="klipput" name="klipput" style="font-family: tahoma; font-size: 8pt;"> Klipp ut</span>
</div>
<div id="klistrain" name="klistrain" width="108" onClick="doPaste()" onmouseover="this.style.background='#0A246A'; this.style.color='#ffffff'" onmouseout="this.style.background='#D4D0C8'; this.style.color='#000000'" style="background='#D4D0C8'; cursor: default; font-family: tahoma; font-size: 8pt;">
Klistra in
</div>
onmouseover="this.style.background[B]Color[/B]='#0A246A'; this.style.color='#ffffff'"
Själva onmouseover funktionen fungerar. Felet är när man kör functionen contextMeny() som onmouseovereffekten slutar att fungera.
När clipboard är tom så ska ju inte mouseovereffekten vara aktiv, men när clipboardet innehåller något ska mouseovereffekten vara aktiv igen.
Addeladde skrev:
Själva onmouseover funktionen fungerar. Felet är när man kör functionen contextMeny() som onmouseovereffekten slutar att fungera.
När clipboard är tom så ska ju inte mouseovereffekten vara aktiv, men när clipboardet innehåller något ska mouseovereffekten vara aktiv igen.
Går det verkligen att göra så som du vill? :o
OnMouseOver är väl ingen DOM object så att du kan sätta den hur du vill. Eller har jag missat något?
Jag har ingen aning om man kan göra så. Tydligen inte eftersom det inte fungerar.
Kan man göra på något annat sätt?
/Andreas
Jag skulle göra något sådant istället...
<div id="klistrain" name="klistrain" width="108" onClick="doPaste()" onmouseover="funcOver()" onmouseout="funcOut()" style="background='#D4D0C8'; cursor: default; font-family: tahoma; font-size: 8pt;">
Klistra in</div>
Sedan måste du naturligtsvis ha de functioner som anropas vid onmouseover och onmouseout
function funcOver(){
if (clipboardData.getData("Text") == null) {
document.getElementById('klistrain').backgroundColor = '#0A246A';
document.getElementById('klistrain').color = '#ffffff';
}
}
function funcOut(){
document.getElementById('klistrain').backgroundColor = '#D4D0C8';
document.getElementById('klistrain').color = '#000000';
}
Funkar inte
Får du nåt fel eller vad?
Är det där "hela sidan" så förstår jag att det blir fel. Kan du inte posta hela sidan ;)
Så här ser hela sidan ut just nu.
<html>
<head>
<script>
//Context Meny ################################################################
var Xmouse=0; var Ymouse=0;
function MoveHandler(evnt) {
if(document.all){
Xmouse = window.event.x+document.body.scrollLeft;
Ymouse = window.event.y+document.body.scrollTop;
} else if(document.getElementById) {
Xmouse = evnt.pageX;
Ymouse = evnt.pageY;
}
}
document.onmousemove = MoveHandler;
//#############################################################################
function contextMeny() {
if (clipboardData.getData("Text") == null) {
klistrain.disabled = true;
}
else {
klistrain.style.disabled = false;
}
markerattxt = document.selection.createRange().text;
if (markerattxt != '') {
klipput.disabled = false;
}else{
klipput.disabled = true;
}
}
</script>
</head>
<body oncontextmenu="contextMeny(); document.getElementById('oContextHTML').style.top=Ymouse; document.getElementById('oContextHTML').style.left=Xmouse; document.getElementById('oContextHTML').style.visibility='visible'; return false;" onclick="document.getElementById('oContextHTML').style.visibility='hidden'">
<p>Här är lite text om man vill markera.</p>
<div class="ruta" ID="oContextHTML" STYLE="position:absolute; visibility:hidden; width: 108;">
<div width="108" style="background='#D4D0C8'; border-right: 1px solid #404040; border-left: 1px solid #D4D0C8; border-top: 1px solid #D4D0C8; border-bottom: 1px solid #404040;">
<div width="108" style="background='#D4D0C8'; border-right: 1px solid #808080; border-left: 1px solid #ffffff; border-top: 1px solid #ffffff; border-bottom: 1px solid #808080;">
<div id="klipput" name="klipput" width="108" onClick="doCut()" onmouseover="this.style.background='#0A246A'; this.style.color='#ffffff';" onmouseout="this.style.background='#D4D0C8'; this.style.color='#000000'" style="background='#D4D0C8'; cursor: default; font-family: tahoma; font-size: 8pt; height: 17px; vertical-align: middle;">
Klipp ut
</div>
<div id="klistrain" name="klistrain" width="108" onClick="doPaste()" onmouseover="this.style.background='#0A246A'; this.style.color='#ffffff';" onmouseout="this.style.background='#D4D0C8'; this.style.color='#000000'" style="background='#D4D0C8'; cursor: default; font-family: tahoma; font-size: 8pt; height: 17px; vertical-align: middle;">
Klistra in
</div>
</div>
</div>
</div>
</body>
</html>
Jag måste ha varit trött igår när jag inte såg detta...
Ändra mina funktioner som du fick ovan så att de ser ut så här istället:
function funcOver(){
if (clipboardData.getData("Text") == null) {
document.getElementById('klistrain')[B].style[/B].backgroundColor = '#0A246A';
document.getElementById('klistrain')[B].style[/B].color = '#ffffff';
}
}
function funcOut(){
document.getElementById('klistrain')[B].style[/B].backgroundColor = '#D4D0C8';
document.getElementById('klistrain')[B].style[/B].color = '#000000';
}
OK tack