IE,手機都好使
谷歌和360不執行
程序是點擊選擇材料--選擇“金”---在型號里應彈出4135 4140 4340。但谷歌和360彈不出來。
哪的病呢?
<select onchange="populateAlloy(document.weightcalc,document.weightcalc.material.options[document.weightcalc.material.selectedIndex].value)" name="material">
<option value="" selected="">選擇材料</option>
<option value="https://bbs.csdn.net/topics/alloysteel">金</option>
</select>
<select name="alloy">
<option value="" selected="">型號</option>
</select>
<script type="text/javascript">
var alloysteelArray = new Array("('選擇貴金屬','',true,true)",
"('4135','0.282')",
"('4140','0.282')",
"('4340','0.282')");
function populateAlloy(inForm,selected) {
var selectedArray = eval(selected + "Array");
while (selectedArray.length < inForm.alloy.options.length) {
inForm.alloy.options[(inForm.alloy.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
eval("inForm.alloy.options[i]=" + "new Option" + selectedArray[i]);
}
if (inForm.material.options[0].value == '') {
inForm.material.options[0]= null;
if ( navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}
else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0);
}
}
}
}
}
var focusflag = false;
var RoundOff = 5;
function ConvertToInch(value,type){
if(type=="ft")
value = value*12;
if(type=="yd")
value = value*36;
if(type=="cm")
value = value/2.54;
if(type=="m")
value = (value*100)/2.54;
if(type== "mm")
value = (value/10)/2.54;
return value;
}
function CalculateWeight(){
var Param = new Array(5);
var Units = new Array(4);
var Convert;
var FormType;
var Result;
var Good;
var myShape;
var myPieces;
var myDensity;
var myWeight;
var myPcWeight;
var totalWeight;
var dim1;
var dim2;
var dim3;
var dim4;
myDensity = document.weightcalc.alloy.value;
dim1 = ConvertToInch(document.weightcalc.dim1.value,document.weightcalc.unitsdim1.value);
dim2 = ConvertToInch(document.weightcalc.dim2.value,document.weightcalc.unitsdim2.value);
dim3 = ConvertToInch(document.weightcalc.dim3.value,document.weightcalc.unitsdim3.value);
dim4 = ConvertToInch(document.weightcalc.dim4.value,document.weightcalc.unitsdim4.value);
myPieces = document.weightcalc.pieces.value;
myShape = document.weightcalc.matshape.value;
document.weightcalc.pcweight.rsize = "4";
document.weightcalc.totalweight.rsize = "4";
if(myShape=="round"){
myWeight=new String(dim1*dim1*9.42*myDensity*(dim2/12));
document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff)* 0.4535;
}
if(myShape=="square"){
myWeight=new String(dim1*dim1*myDensity*dim2);
document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff)* 0.4535;
}
if(myShape=="hex"){
myWeight=new String(dim1*dim1*myDensity*10.4*(dim2/12));
document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff)* 0.4535;
}
if(myShape=="flat"){
myWeight=new String(dim1*dim2*myDensity*dim3);
document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff)* 0.4535;
}
if(myShape=="rectangle"){
myWeight=new String(dim1*dim2*myDensity*dim3);
document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff)* 0.4535;
}
if(myShape=="tube"||myShape=="pipe"){
myWeight=new String((dim1-dim2)*dim2*myDensity*37.7*(dim3/12));
document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff)* 0.4535;
}
if(myShape=="rectangle tube"){
myWeight=new String(((dim1*dim2*12*myDensity)-((dim1-(dim3*2))*(dim2-(dim3*2))*12*myDensity))*(dim4/12));
document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff)* 0.4535;
}
if(myShape=="square tube"){
myWeight=new String(37.7*myDensity*dim2*(dim1-dim2)*1.27*(dim3/12));
document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff)* 0.4535;
}
myPcWeight=document.weightcalc.pcweight.value;
totalWeight=new String(myPcWeight*myPieces);
totalWeight = totalWeight.substring(0,myWeight.indexOf(".")+RoundOff);
document.weightcalc.totalweight.value=https://bbs.csdn.net/topics/totalWeight;
}
function ClearFields(){
document.weightcalc.dim1.value = "";
document.weightcalc.dim2.value = "";
document.weightcalc.dim3.value = "";
document.weightcalc.dim4.value = "";
document.weightcalc.pcweight.value = "";
document.weightcalc.totalweight.value = "";
}
function ChangeLabel(){
var myShape;
myShape = document.weightcalc.matshape.value;
if(myShape=="round"){
document.weightcalc.dim1label.value = "直徑:";
document.weightcalc.dim2label.value = "長度:";
document.weightcalc.dim3label.value = "";
document.weightcalc.dim4label.value = "";
}
}
ChangeLabel();
ClearFields();
</SCRIPT>
uj5u.com熱心網友回復:
if ( navigator.appName == 'Netscape') {if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}
else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0);
}
}
}
把這些代碼洗掉,這些沒什么用
uj5u.com熱心網友回復:
回2樓 洗掉也不行uj5u.com熱心網友回復:
這段代碼是想做什么?邏輯通嗎?if (inForm.material.options[0].value == '') {
inForm.material.options[0] = null;
if (navigator.appName == 'Netscape') {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}
else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
window.history.go(0);
}
}
}
}
uj5u.com熱心網友回復:
我不太懂呀,所以請大家幫忙
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/79741.html
標籤:JavaScript
