nemmeste løsning vil være at skifte onclick="switchdis();" til onmouseover="switchdis();" så bliver focus ikke sat til feltet...
har fået problemet med onclick løst med ff dog kan jeg ikke rigtig
få ie til at huske tidligere selection position... men med onmouseover
som nedenunder virker det...
her er lige et eksempel (ikke for kønt):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><title>Ingen titel</title>
<style type="text/css">
.imgbuttom{position:absolute;right:0;top:0;width:20px;}
.dropdownbox{position:absolute;z-index:1;width:150px;display:none;border:4px dashed red;background-color:white;}
</style>
<script type="text/javascript">
<!--
function switchdis(){
if(document.getElementById("dropbox2").style.display!="block"){
document.getElementById("dropbox2").style.display="block";
}else{
document.getElementById("dropbox2").style.display="none";
}
}
window.onload=function(){
document.getElementById("dropbox2").style.top=document.getElementById("dropbox1").offsetTop;
document.getElementById("dropbox2").style.left=document.getElementById("dropbox1").offsetLeft;
}
mytxt="";
mytxts="";
mytxte="";
mycurtxtl="";
myvalue="";
function findselect(mytag){
mytxtarea=document.formnavn.txtareanavn;
if(document.selection){
mytxt=document.selection.createRange().text;
if(mytxt!="")document.selection.createRange().text="["+mytag+"]"+mytxt+"[/"+mytag+"]";
}else if((mytxtarea.selectionEnd-mytxtarea.selectionStart)>0){
mytxts=mytxtarea.selectionStart;
mytxte=mytxtarea.selectionEnd;
mycurtxtl=mytxtarea.textLength;
myvalue=mytxtarea.value;
mytxtarea.value=mytxtarea.value.substr(0,mytxts)+"["+mytag+"]"+mytxtarea.value.substr(mytxts,mytxte-mytxts)+"[/"+mytag+"]"+mytxtarea.value.substr(mytxte,mycurtxtl);
}
}
//-->
</script></head>
<body>
<form method="POST" action="#" name="formnavn">
<div id="dropbox2" class="dropdownbox">
<input type="button" onclick="findselect('b');switchdis();" value="Fed skrift">
<input type="button" onclick="findselect('i');switchdis();" value="Kursiv skrift">
<input type="button" onclick="findselect('u');switchdis();" value="Understreget skrift">
</div>
<div style="position:relative;width:150px;" id="dropbox1">
<input type="text" id="dropbox1inp" name="nametilinputtet" size="10" onkeyup="this.value='';" onmouseover="switchdis();" style="width:100px;display:block;padding:0px;margin:0px;" value="Tilføj tag">
<img src="img.gif" onmouseover="switchdis();" class="imgbuttom" alt="img">
</div>
<textarea rows="5" name="txtareanavn" cols="20"></textarea>
</form>
</body></html>