PDA

View Full Version : please help, strange IE7 Javascript woes :(


Leeoniya
09-18-2006, 02:03 AM
why does this line work in opera and firefox, but not ie7?

<input type="text" name="LS-A" value="" size="1" onchange="recalc()" />

i added an "alert('hi');" as the first line of the recalc function
ff and opera work fine and display the messagebox, but ie7 doesn't seem to even go into the function at all.

can this have anything to do what's inside the function after the messagebox?

i get no syntax errors in Dreamweaver, ff, or opera....not one error.

please help, :confused:
Leon

Arbitrator
09-18-2006, 02:37 AM
Maybe JavaScript is being blocked? Internet Explorer 7 seems to disable scripts by default; you have to click a little yellow bar at the top of the viewport and select "Allow Blocked Content…" to enable them.

Leeoniya
09-18-2006, 03:07 AM
no, other scripts work.

_Aerospace_Eng_
09-18-2006, 03:11 AM
Pretty strange. It looks like IE7 isn't registering any event handlers inside of input boxes. Notice how the alert from the onload works but doesn't in the input box.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function recalc()
{
alert('hi');
}
window.onload = recalc;
</script>
</head>

<body>
<form action="#" method="post">
<input type="text" change="recalc()" />
</form>
</body>
</html>

See if the above gives you the alert. If it does then its a bug in IE7 RC1

Leeoniya
09-18-2006, 03:23 AM
yeah, that works. i actually suspected it might have been a bug with onchange, so i tried onmouseout, on mouseover, onblur...nothing worked, thats when i came here. :)

i think it's an rc1 bug. pretty huge one at that, considering how much validation is done this way, oh yeah, and everything else.

is there a way to find out if it has been submitted to M$?

Leon

Arbitrator
09-18-2006, 03:37 AM
is there a way to find out if it has been submitted to M$?There's a thing under RC1's help menu labeled "Send Feedback" that'll get you there. More directly, you can go to https://connect.microsoft.com/IE/feedback/Search.aspx. You need a Windows Live ID to access the bug reporting area.

brothercake
09-18-2006, 10:26 AM
Maybe it's inline handlers. Do DOM-based handlers work okay (using the same event on the same element)

I'd laugh if they do! "IE7 loses support for inline handlers" - that'd make my day ;)

Bill Posters
09-18-2006, 11:19 AM
Reminds me of an IE6(?) bug whereby onchange events added via js will actually appear in the rendered DOM, but won't actually work.
Possibly related.

…iirc.

Leeoniya
09-18-2006, 11:29 AM
yes, DOM-based handlers still work. i didnt even know they could be assigned through DOM :), did some searching, found some snippets adapted them with some logic loops.

ff is happy, ie7 is happy, opera is happy
so i'm happy with this workaround, less html to maintain anyways since the function has no args - it just keeps a running total, so pointless to use identical inline on 100-some inputs, clean is good :)

still a bug to squash tho.

Leon

akaioi
06-07-2007, 10:43 PM
This is an old topic, but I thought I should post a note about it, because I
wasted two hours on it...

In IE7 there is a built-in function document.recalc(). It refreshes style rules after a DOM change. This is interfering with your recalc() function ... it is getting called instead of your recalc.

If you change the name of your function to recalculate() all will be well.

Here's a doc about recalc:
http://dean.edwards.name/IE7/compatibility/recalc.html

Leeoniya
06-09-2007, 05:03 AM
good find akaioi.