Javascript runs on an HTML Page but Not on WordPress
-
I installed a javascript on an HTML page and it works perfectly – you can see it here – https://source-pro.org/PPT-Calc-Windows.html
The same code when added to a WordPress Page utilizing a Custom Field does not work – you can see it here – https://source-pro.org/inches-to-pixels-and-saving/
This is the javascript
<script type="text/javascript"> var vals = [1/3, 2/3, 3/3, 1/4, 2/4, 3/4, 4/4]; var tmp = 0; str += '\nValue display using .toFixed(3) then truncates\n'; for (var i=0; i<vals.length; i++) { tmp = vals[i].toFixed(3); str += tmp.substr(0,tmp.length-1)+'\n'; } document.getElementById('debug').innerHTML = str; </script> <script type="text/javascript"> function compute_p (obj) { with (Math) { u4=eval(obj.einh.value); d4=eval(obj.cmheight1.value); d5=eval(obj.cmwidth1.value); d8=eval(obj.cmresolution.value); if (obj.einh[1].checked) { h5=d4*d8; h6=d5*d8; } else { h5=(d4/2.54)*d8; h6=(d5/2.54)*d8; } s1=((h5*h6*3)/1024)/1024; s2=round(h5)*round(h6); function rounder(x,stellen) { return (Math.round(x*Math.pow(10,stellen)))/Math.pow(10,stellen) } obj.res5.value =round(h5); obj.res6.value =round(h6); obj.sres.value =rounder(s1,2); obj.sres_pix.value =round(s2); } } function compute (obj) { with (Math) { d1=eval(obj.height1.value); d2=eval(obj.width1.value); d3=eval(obj.resolution.value=96); h1=(d1/d3)*2.54; h2=(d2/d3)*2.54; h3=d1/d3; h4=d2/d3; tmp = h3.toFixed(4); obj.res3.value = tmp.substr(0,tmp.length-1)+'\n'; tmp = h4.toFixed(4); obj.res4.value = tmp.substr(0,tmp.length-1)+'\n'; } } </script>
Can anyone see anything that would cause this code to fail when in WordPress?
I’ve tried disabling all plugins – not effect.
I’m stumped.
Any suggestions?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Javascript runs on an HTML Page but Not on WordPress’ is closed to new replies.