---
title: "Ändra mouseover"
type: "forum-thread"
url: "https://www.webforum.nu/amne/javascript/65605-ändra-mouseover"
topic: "JavaScript"
topic_url: "https://www.webforum.nu/amne/javascript"
author: "Addeladde"
published: "2003-01-20T23:09:14.000Z"
updated: "2003-01-21T16:54:56.000Z"
replies: 13
views: 272
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/javascript/65605-ändra-mouseover"
---

# Ändra mouseover

## #1 — Addeladde, 2003-01-20T23:09Z

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.
```

Permalänk: https://www.webforum.nu/p/65605

## #2 — Nickemannen, 2003-01-20T23:16Z

onmouseover="this.style.background='#0A246A'; this.style.color='#ffffff'"

vad är klistrain.onmouseover ? testa att sätta , tecken mellan funktionerna

Permalänk: https://www.webforum.nu/p/920470

## #3 — Addeladde, 2003-01-20T23:20Z

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;">&nbsp;&nbsp;&nbsp;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;">
			  &nbsp;&nbsp;&nbsp;Klistra in
			  </div>
```

Permalänk: https://www.webforum.nu/p/920475

## #4 — Darren, 2003-01-20T23:37Z

```
onmouseover="this.style.background[B]Color[/B]='#0A246A'; this.style.color='#ffffff'"
```

Permalänk: https://www.webforum.nu/p/920493

## #5 — Addeladde, 2003-01-20T23:42Z

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.

Permalänk: https://www.webforum.nu/p/920501

## #6 — Darren, 2003-01-20T23:46Z

> **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?

Permalänk: https://www.webforum.nu/p/920504

## #7 — Addeladde, 2003-01-20T23:50Z

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

Permalänk: https://www.webforum.nu/p/920506

## #8 — Darren, 2003-01-20T23:59Z

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';
}
```

Permalänk: https://www.webforum.nu/p/920515

## #9 — Addeladde, 2003-01-21T00:12Z

Funkar inte

Permalänk: https://www.webforum.nu/p/920524

## #10 — Darren, 2003-01-21T00:14Z

Får du nåt fel eller vad?

Permalänk: https://www.webforum.nu/p/920526

## #11 — Jesper T, 2003-01-21T00:18Z

Är det där "hela sidan" så förstår jag att det blir fel. Kan du inte posta hela sidan ;)

Permalänk: https://www.webforum.nu/p/920529

## #12 — Addeladde, 2003-01-21T00:31Z

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;">
					&nbsp;&nbsp;&nbsp;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;">
			 	  &nbsp;&nbsp;&nbsp;Klistra in
			 	  </div>
		  </div>
		</div>
</div>

</body>
</html>
```

Permalänk: https://www.webforum.nu/p/920533

## #13 — Darren, 2003-01-21T16:13Z

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';
}
```

Permalänk: https://www.webforum.nu/p/924028

## #14 — Addeladde, 2003-01-21T16:54Z

OK tack

Permalänk: https://www.webforum.nu/p/924070

---

Tråden på webben: https://www.webforum.nu/amne/javascript/65605-ändra-mouseover
