Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#sel {
position:absolute;
}
</style>
<script type="text/javascript">
function openSel(el){
var el = document.getElementById(el)
var el1 = el.cloneNode(true);
el1.size = el.options.length;
el.parentNode.replaceChild(el1, el);
}
</script>
</head>
<body>
<input type="button" value="open" onclick="openSel('sel');"><br>
<div style="position:relative;float:left;width:4em;height:1.2em;"><select id="sel" onclick="this.size=1">
<option value="1">Hello1</option>
<option value="1">Hello2</option>
<option value="1">Hello3</option>
<option value="1">Hello4</option>
<option value="1">Hello5</option>
<option value="1">Hello6</option>
<option value="1">Hello7</option>
<option value="1">Hello8</option>
</select></div>
<div style="clear:left;">other content</div>
</body>
</html>
Notes: Cloning and replacing the node was only required in Opera to overcome an apparent bug in assigning a size to a select that had no size attribute or one of 1 or less. Otherwise, it could have been:
Code:
function openSel(el){
var el = document.getElementById(el)
el.size = el.options.length;
}
Bookmarks