Van_Gogh
February 9th, 2007, 12:37 AM
Hi,
I'm trying to get a site's javascript to work with Mozilla Firefox. I'm trying to get JavaScript to correctly resize a div. The code is almost working, but the onMouseUp works differently for FF than for IE or Opera.
That is, clicking and resizing a <td> element works fine for all browsers, but on <td><img></td> Firefox won't let onMouseUp run and set move to false.
For reference, this is the script. I'd appreciate any help.
<script>
// Resize listboxes
var move = false;
var position;
var new_position;
var listbox;
document.onmouseup = onMouseUp;
document.onmousemove = onMouseMove;
function onMouseDown(event, boxno)
{
move = true;
if(event) position = event.pageX
else position = window.event.x;
listbox = boxno;
}
function onMouseMove(event)
{
if (move)
{
if(event) new_position = event.pageX
else new_position = window.event.x;
ResizeListbox(new_position - position, listbox);
position = new_position;
return false;
}
}
function onMouseUp()
{
move = false;
}
function ResizeListbox(whereto, boxno)
{
var begin = document.forms['main'].elements[boxno].style.width;
var intbegin = parseInt(begin);
var newwidth = intbegin + whereto;
if (newwidth > 0)
{
document.forms['main'].elements[boxno].style.width = newwidth;
}
}
//-->
</script>
I'm trying to get a site's javascript to work with Mozilla Firefox. I'm trying to get JavaScript to correctly resize a div. The code is almost working, but the onMouseUp works differently for FF than for IE or Opera.
That is, clicking and resizing a <td> element works fine for all browsers, but on <td><img></td> Firefox won't let onMouseUp run and set move to false.
For reference, this is the script. I'd appreciate any help.
<script>
// Resize listboxes
var move = false;
var position;
var new_position;
var listbox;
document.onmouseup = onMouseUp;
document.onmousemove = onMouseMove;
function onMouseDown(event, boxno)
{
move = true;
if(event) position = event.pageX
else position = window.event.x;
listbox = boxno;
}
function onMouseMove(event)
{
if (move)
{
if(event) new_position = event.pageX
else new_position = window.event.x;
ResizeListbox(new_position - position, listbox);
position = new_position;
return false;
}
}
function onMouseUp()
{
move = false;
}
function ResizeListbox(whereto, boxno)
{
var begin = document.forms['main'].elements[boxno].style.width;
var intbegin = parseInt(begin);
var newwidth = intbegin + whereto;
if (newwidth > 0)
{
document.forms['main'].elements[boxno].style.width = newwidth;
}
}
//-->
</script>