rbartz
asked on
Javascript Division in IE10 compatibility mode
Can someone tell me why the following function works in Firefox, Chrome, and IE10 but NOT when running IE10 in compatibility mode?
The error in console is here: gpm = (dia*dia*2.56*horz)/Math.s qrt(vert);
The error is SCRIPT438: Object doesn't support this property or method
<script type="text/javascript">
function calcGpm() {
var dia = document.forms[0].dia.valu e;
var horz = document.forms[0].horz.val ue;
var vert = document.forms[0].vert.val ue;
gpm = (dia*dia*2.56*horz)/Math.s qrt(vert);
gpm2 = Math.round(gpm*Math.pow(10 ,2))/Math. pow(10,2);
if(gpm2 > 0 ) {
document.getElementById('g pm').inner HTML = '<b>'+gpm2+'</b>';
document.getElementById('g ph').inner HTML = commafyNumber(gpm2*60);
document.getElementById('g pd').inner HTML = commafyNumber(gpm2*1440);
}
}
function commafyNumber( number ) {
number = '' + number
var withcommas = number.replace(/(^|[^\w.]) (\d{4,})/g , function($0, $1, $2) {
return $1 + $2.replace(/\d(?=(?:\d\d\d )+(?!\d))/ g, "$&,")
})
return withcommas
}
</script>
The error in console is here: gpm = (dia*dia*2.56*horz)/Math.s
The error is SCRIPT438: Object doesn't support this property or method
<script type="text/javascript">
function calcGpm() {
var dia = document.forms[0].dia.valu
var horz = document.forms[0].horz.val
var vert = document.forms[0].vert.val
gpm = (dia*dia*2.56*horz)/Math.s
gpm2 = Math.round(gpm*Math.pow(10
if(gpm2 > 0 ) {
document.getElementById('g
document.getElementById('g
document.getElementById('g
}
}
function commafyNumber( number ) {
number = '' + number
var withcommas = number.replace(/(^|[^\w.])
return $1 + $2.replace(/\d(?=(?:\d\d\d
})
return withcommas
}
</script>
work fine for me on IE10 : http://jsfiddle.net/NwGFE/
Works for me as well on IE10 compatibility mode
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Julian H,
That was it! var gpm must be something special to javascript somewhere in older versions of IE. Changed it to gpm1 and now the script works in all browsers as it should have!
Thank you Julian! And thanks to tagit and leakim971 for trying.
Richard
That was it! var gpm must be something special to javascript somewhere in older versions of IE. Changed it to gpm1 and now the script works in all browsers as it should have!
Thank you Julian! And thanks to tagit and leakim971 for trying.
Richard
You are welcome - thanks for the points.
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_sqrt3