1去年,Chrome 進行了更新,阻止某些 javascript 正常作業。我可以在 Internet Explorer 中使用它,但它在 Firefox、Edge 或 Chrome 中不起作用。
選擇在PCPSELECT變數中檢查的特定零件時,與該部分相關的序列號將自動顯示在文本框中。但它現在被阻止了,我現在無法讓 DOM 正常作業。有沒有人有什么建議?這是從下拉串列中選擇零件編號后的錯誤截圖
function fillSerial()
{
var pcpSelect = document.frm_CreatePCP.PCP_ID.selectedIndex;
var PCP = document.frm_CreatePCP.PCP_ID(pcpSelect).value;
//alert(PCP);
for (var i = 1; i < PCP_array.length; i )
{
if ( PCP == PCP_array[i] )
{
document.frm_CreatePCP.sn.value = Number(Serial_array[i]) 1;
document.frm_CreatePCP.sn.refresh;
document.frm_CreatePCP.part.value=PCP;
//document.getElementById("openserial").onclick="javascript:void window.open('selectExistSerial.cfm?pcp_id=' PCP ','1351625603240','width=300,height=150,resizable=1,left=650,top=300');" ;
document.getElementById("openserial").disabled = false;
break;
}
}
}
function openSerialWindow()
{
var pcpSelect = document.frm_CreatePCP.PCP_ID.selectedIndex;
var PCP = document.frm_CreatePCP.PCP_ID(pcpSelect).value;
if (PCP.length < 1) {
alert ("Part is required");
document.frm_CreatePCP.PCP_ID.focus();
}
else
{
//alert(PCP);
//mywindow = window.open("'selectExistSerial.cfm?pcp_id=' PCP ','1351625603240','width=300,height=150,resizable=1,left=650,top=300'");
mywindow = window.open('selectExistSerial.cfm?pcp_id=' PCP,'mywindow','width=650,height=350,resizable=1,left=650,top=300,scrollbars=1');
}
}
<form action="man_insp_enter_serial.cfm" name="frm_CreatePCP" method="post" > <!-- changed name to id name="frm_CreatePCP" -->
<input type="hidden" name="part" value="<cfoutput>#form.part#</cfoutput>">
<table border="1" cellpadding="6" cellspacing="2" align="center" >
<tr>
<td align="center" colspan="2" bgcolor="#CCCCCC"><div class="bluem" >Start Manual Inspection Template</div></td></tr>
<tr>
<td align="center" >
<b>Part: </b>
<select name="PCP_ID" onchange="fillSerial();" >
<option value="">Choose One</option>
<SCRIPT language=JavaScript type="text/javascript">
var Serial_array = new Array();
var PCP_array = new Array();
</SCRIPT>
<cfset j=1>
<cfoutput query="qryAporvedPCP">
<option value="#qryAporvedPCP.PCP_ID#" <cfif qryAporvedPCP.PCP_ID eq form.part> selected </cfif> >#qryAporvedPCP.PARTNUM#</option>
<SCRIPT language=JavaScript type= "text/javascript" >
Serial_array[#j#] = "#qryAporvedPCP.MAX_SERIAL#";
PCP_array[#j#] = "#qryAporvedPCP.PCP_ID#";
</SCRIPT>
<cfset j=j 1>
<!-- <cfset ary_PCP_ID = ListToArray( valueList(qryAporvedPCP.PCP_ID) ) >
<cfset ary_SERIAL = ListToArray( valueList(qryAporvedPCP.MAX_SERIAL) ) > -->
</cfoutput>
</select>
</td>
<td >Serial Number: <input type="text" name="sn" size="7" maxlength="7" style="text-transform:uppercase; text-align:center; font-weight:bold" onkeypress="return isNumberDecKey(event);" value="" /> <input type="button" name="openSerial" value ="S/N Used" onclick="javascript: openSerialWindow()" ></td>
<input type="hidden" name="freq" value="0" />
<input type="hidden" name="temp" value="68" />
</tr>
</table>
</form>
uj5u.com熱心網友回復:
我測驗了您的代碼,它在包括 IE 在內的所有瀏覽器中都顯示錯誤。我收到與您的螢屏截圖中相同的錯誤。該錯誤顯示您獲取<select>值的代碼PCP是錯誤的。您可以將代碼編輯為document.frm_CreatePCP.PCP_ID[pcpSelect].value. 然后它可以正確獲取值并在所有瀏覽器中作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/504916.html
標籤:javascript 谷歌浏览器 微软边缘 冷融合-10
