So I am converting some old code to be compatable with Chrome and for whateve reason, the code I had for printing a report (opening it in a new tab) isn't working in Chrome but is fine in IE. I've tried all kinds of different ways with type button and submit, and have poured all over this side and haven't had any results.
因此,我正在转换一些旧的代码以与Chrome兼容,并且由于原因,我用于打印报告的代码(在新标签中打开它)在Chrome中不起作用但在IE中很好。我已经尝试了各种不同的方式与类型按钮和提交,并已倾倒在这一边,并没有任何结果。
This input is inside the form "frmDisplay"
此输入位于“frmDisplay”形式中
<input type="button" id="servlet" name="servlet" value=" Print "
onclick="return printOrder()" />
This is my code that submits the reports
这是我提交报告的代码
function printOrder() {
if (AnyChecked()) {
document.frmDisplay.action = 'PrintOrder.cs';
copyValue = document.getElementById('KanbanCopyNumber').getAttribute('value');
var arrayP = createHiddenElement('ARRAY_PARAMETERS', 'orderNumber');
document.frmDisplay.appendChild(arrayP);
document.frmDisplay.target = "_blank";
var copyNumber = document.createElement('INPUT');
copyNumber.type = 'hidden';
copyNumber.name = 'CopyNumber';
copyNumber.value = copyValue;
document.frmDisplay.appendChild(copyNumber);
document.frmDisplay.target = "_blank";
reportName = document.frmDisplay.rep.getAttribute('value');
if (labels.length == 1) {
reportName = labels[0];
}
else {
if (reportName == null || reportName == '') {
reportName = 'All';
}
}
if (reportName != 'All') {
document.frmDisplay.rep.value = reportName;
document.frmDisplay.submit();
}
else {
for (i = 0; i < labels.length; i++) {
document.frmDisplay.rep.value = labels[i];
document.frmDisplay.submit();
}
document.frmDisplay.rep.value = 'All';
}
for (index = document.frmDisplay.length; index >= 0; index--) {
childElem = document.frmDisplay.childNodes[index];
}
// Force refresh of the view
callSubmit();
}
else {
alert('To generate report at least one order must be selected');
}
return false;
}
Heres the form in its entirety.
完整的形式。
<form name="frmDisplay" method="post" onSubmit="document.getElementById('submit').disabled=true;">
<input type="hidden" name="direction">
<table width="100%" valign="top" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="340">
<div class="nav">
<strong><font color="#db0055"><img width="15" src="images/shim.gif">Orders <input type="text" name="startRow" size="5" value="0">-0 of 0</font></strong>
</div>
</td><td><img width="15" src="images/shim.gif"><font color="blue">This page will refresh every 5 minutes</font></td>
</tr>
</table>
<table class="tabularData" cellpadding="0" cellspacing="0" border="0">
<tr id="controlRow" class="controlRow">
<td nowrap="true" colspan="10"><input type="button" id="servlet" name="servlet" value=" Print " onclick="return printOrder()">
checked orders for report
<input type="hidden" id="rep" name="rep"><script type="text/javascript">
var labelArray = new Array();
var labels = new Array();
labelArray[0] = new Option("All", "All", "", "selected");
labelArray[1] = new Option("2x4 Roll - Proximity", "ek_proximity.jasper");labels[0] = "ek_proximity.jasper";labelArray[2] = new Option("2x4 Roll Label - Rainbird";
writeSelectBox(labelArray, "rep1", 1, "document.frmDisplay.rep.value=this.options[this.selectedIndex].value", "z-index: 99");
</script>
<b># of copies</b> <input type="text" id="KanbanCopyNumber" value="1" size="2" maxlength="2"></td>
</tr>
<tr class="headerRowRefresh">
<!--FILTER GOES HERE-->
<SCRIPT LANGUAGE="JavaScript">
var cal1 = new CalendarPopup();//'CalDiv');
</SCRIPT><td colspan="10">
Display
<input type="hidden" name="pageSize" value="20"><script type="text/javascript">
var pageArray = new Array();
pageArray[0] = new Option("10", "10");pageArray[1] = new Option("20", "20", "", "selected");pageArray[2] = new Option("50", "50");pageArray[3] = new Option("100", "100");
writeSelectBox(pageArray, "pageSize1", 1, "document.frmDisplay.pageSize.value=this.options[this.selectedIndex].value", "font-family: verdana, arial, helvetica, sans-serif;font-size: 10px;z-index: 99");
</script>
matches per page
<input type="hidden" name="pageNbr" value="1">
<input name="submitButton" onClick="callSubmit(); return false;" type="submit" value="Refresh Data">
<input name="submitButton" onclick="callResetFilter(); return false;" type="submit" value="Reset Filters"><input type="hidden" name="cmdQuery"></td>
</tr>
<tr valign="top">
<td valign="top">
<table class="tabularData" cellpadding="0" cellspacing="0" border="0" height="100%">
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr class="headerRowTitle" height="23" valign="top">
<td> </td><td nowrap="true">Order#</td><td nowrap="true">Printed</td><td nowrap="true">Status</td>
</tr>
<tr class="headerRow" height="28" valign="top">
<td> </td><td nowrap="true"><input align="left" size="10" name="filterOrder" value=""></td><td nowrap="true"><input type="hidden" name="filterPrinted"><script type="text/javascript">
var optionArray = new Array();
optionArray[0] = new Option(" - All - ", " ", "font-family:Verdana;font-size:10px;");optionArray[1] = new Option("Yes", "1", "font-family:Verdana;font-size:10px;");optionArray[2] = new Option("No", "0", "font-family:Verdana;font-size:10px;", "selected");document.frmDisplay.filterPrinted.value="0";optionArray[3] = new Option("N/A", "-1", "font-family:Verdana;font-size:10px;");writeSelectBox(optionArray, "filterPrinted1", 1, "document.frmDisplay.filterPrinted.value=this.options[this.selectedIndex].value", "font-family: verdana, arial, helvetica, sans-serif;font-size: 10px;vertical-align: middle;z-index: 0;width:120");</script></td><td nowrap="true"><input type="hidden" name="status"><script type="text/javascript">
var optionArray = new Array();
optionArray[0] = new Option(" - All - ", " ", "font-family:Verdana;font-size:10px;");optionArray[1] = new Option("Not Canceled", "P", "font-family:Verdana;font-size:10px;");optionArray[2] = new Option("Open", "O", "font-family:Verdana;font-size:10px;");optionArray[3] = new Option("Waiting Approval", "A", "font-family:Verdana;font-size:10px;");optionArray[4] = new Option("Partially Received", "R", "font-family:Verdana;font-size:10px;");optionArray[5] = new Option("Sent", "S", "font-family:Verdana;font-size:10px;");optionArray[6] = new Option("Canceled", "X", "font-family:Verdana;font-size:10px;");optionArray[7] = new Option("Closed", "Z", "font-family:Verdana;font-size:10px;");writeSelectBox(optionArray, "status1", 1, "document.frmDisplay.status.value=this.options[this.selectedIndex].value", "font-family: verdana, arial, helvetica, sans-serif;font-size: 10px;vertical-align: middle;z-index: 0;width:120");</script></td>
</tr>
</table>
</td>
</tr>
</table>
</td><td align="left" valign="top">
<table class="tabularData" cellpadding="0" cellspacing="0" border="0" height="100%">
<tr>
<td width="100%">
<table cellspacing="0" cellpadding="0" border="0" width="100%" id="scrollTable">
<tr class="headerRowTitle" height="23" valign="top">
<td nowrap="true">Part#</td><td nowrap="true">Location</td><td nowrap="true">Site</td><td nowrap="true">Price</td><td nowrap="true">Mfr</td><td nowrap="true">Mfr Part#</td><td nowrap="true">Qty</td><td nowrap="true">Qty Open</td><td nowrap="true">Supplier</td><td nowrap="true">PO</td><td nowrap="true">PO Line</td><td nowrap="true">Date Created</td><td nowrap="true">Due Date</td><td nowrap="true">User</td><td nowrap="true">Buyer</td><td nowrap="true">Note</td><td nowrap="true">O1</td><td nowrap="true">O2</td><td nowrap="true">O3</td><td nowrap="true">F4</td><td nowrap="true">F10</td>
</tr>
<tr class="headerRow" height="28" valign="top">
<td><input align="left" size="15" name="filterPart" value=""></td><td><input align="left" size="10" name="filterLocation" value=""></td><td><input type="hidden" name="filterSite"><script type="text/javascript">
var optionArray = new Array();
optionArray[0] = new Option(" - All - ", "", "font-family:Verdana;font-size:10px;");optionArray[1] = new Option("007", "007", "font-family:Verdana;font-size:10px;");optionArray[2] = new Option("07", "07", "font-family:Verdana;font-size:10px;");optionArray[3] = new Option("081730", "081730", "font-family:Verdana;font-size:10px;");optionArray[4] = new Option("11", "11", "font-family:Verdana;font-size:10px;");optionArray[5] = new Option("12", "12", "font-family:Verdana;font-size:10px;");optionArray[6] = new Option("13", "13", "font-family:Verdana;font-size:10px;");optionArray[7] = new Option("13&", "13&", "font-family:Verdana;font-size:10px;");optionArray[8] = new Option("14", "14", "font-family:Verdana;font-size:10px;");optionArray[9] = new Option("140", "140", "font-family:Verdana;font-size:10px;");optionArray[10] = new Option("15", "15", "font-family:Verdana;font-size:10px;");optionArray[11] = new Option("16", "16", "font-family:Verdana;font-size:10px;");optionArray[12] = new Option("19", "19", "font-family:Verdana;font-size:10px;");optionArray[13] = new Option("2001", "2001", "font-family:Verdana;font-size:10px;");optionArray[14] = new Option("2002", "2002", "font-family:Verdana;font-size:10px;");optionArray[15] = new Option("32", "32", "font-family:Verdana;font-size:10px;");optionArray[16] = new Option("400", "400", "font-family:Verdana;font-size:10px;");optionArray[17] = new Option("402", "402", "font-family:Verdana;font-size:10px;");optionArray[18] = new Option("403", "403", "font-family:Verdana;font-size:10px;");optionArray[19] = new Option("41", "41", "font-family:Verdana;font-size:10px;");optionArray[20] = new Option("604", "604", "font-family:Verdana;font-size:10px;");optionArray[21] = new Option("605", "605", "font-family:Verdana;font-size:10px;");optionArray[22] = new Option("680", "680", "font-family:Verdana;font-size:10px;");optionArray[23] = new Option("69", "69", "font-family:Verdana;font-size:10px;");optionArray[24] = new Option("786104", "786104", "font-family:Verdana;font-size:10px;");optionArray[25] = new Option("87", "87", "font-family:Verdana;font-size:10px;");optionArray[26] = new Option("A1A", "A1A", "font-family:Verdana;font-size:10px;");optionArray[27] = new Option("ARG", "ARG", "font-family:Verdana;font-size:10px;");optionArray[28] = new Option("AVK", "AVK", "font-family:Verdana;font-size:10px;");optionArray[29] = new Option("AVNET", "AVNET", "font-family:Verdana;font-size:10px;");optionArray[30] = new Option("B1", "B1", "font-family:Verdana;font-size:10px;");optionArray[31] = new Option("BBY", "BBY", "font-family:Verdana;font-size:10px;");optionArray[32] = new Option("D1", "D1", "font-family:Verdana;font-size:10px;");optionArray[33] = new Option("DAL", "DAL", "font-family:Verdana;font-size:10px;");optionArray[34] = new Option("DEL1", "DEL1", "font-family:Verdana;font-size:10px;");optionArray[35] = new Option("DEL10", "DEL10", "font-family:Verdana;font-size:10px;");optionArray[36] = new Option("DEL11", "DEL11", "font-family:Verdana;font-size:10px;");optionArray[37] = new Option("DEL12", "DEL12", "font-family:Verdana;font-size:10px;");optionArray[38] = new Option("DEL13", "DEL13", "font-family:Verdana;font-size:10px;");optionArray[39] = new Option("DEL14", "DEL14", "font-family:Verdana;font-size:10px;");optionArray[40] = new Option("DEL15", "DEL15", "font-family:Verdana;font-size:10px;");optionArray[41] = new Option("DEL16", "DEL16", "font-family:Verdana;font-size:10px;");optionArray[42] = new Option("DEL17", "DEL17", "font-family:Verdana;font-size:10px;");optionArray[43] = new Option("DEL18", "DEL18", "font-family:Verdana;font-size:10px;");optionArray[44] = new Option("DEL19", "DEL19", "font-family:Verdana;font-size:10px;");optionArray[45] = new Option("DEL2", "DEL2", "font-family:Verdana;font-size:10px;");optionArray[46] = new Option("DEL20", "DEL20", "font-family:Verdana;font-size:10px;");optionArray[47] = new Option("DEL21", "DEL21", "font-family:Verdana;font-size:10px;");optionArray[48] = new Option("DEL22", "DEL22", "font-family:Verdana;font-size:10px;");optionArray[49] = new Option("DEL3", "DEL3", "font-family:Verdana;font-size:10px;");optionArray[50] = new Option("DEL4", "DEL4", "font-family:Verdana;font-size:10px;");optionArray[51] = new Option("DEL5", "DEL5", "font-family:Verdana;font-size:10px;");optionArray[52] = new Option("DEL6", "DEL6", "font-family:Verdana;font-size:10px;");optionArray[53] = new Option("DEL7", "DEL7", "font-family:Verdana;font-size:10px;");optionArray[54] = new Option("DEL8", "DEL8", "font-family:Verdana;font-size:10px;");optionArray[55] = new Option("DEL9", "DEL9", "font-family:Verdana;font-size:10px;");optionArray[56] = new Option("ECONTROLS", "ECONTROLS", "font-family:Verdana;font-size:10px;");optionArray[57] = new Option("ECT", "ECT", "font-family:Verdana;font-size:10px;");optionArray[58] = new Option("FL01", "FL01", "font-family:Verdana;font-size:10px;");optionArray[59] = new Option("FL04", "FL04", "font-family:Verdana;font-size:10px;");optionArray[60] = new Option("FWB", "FWB", "font-family:Verdana;font-size:10px;");optionArray[61] = new Option("LEX", "LEX", "font-family:Verdana;font-size:10px;");optionArray[62] = new Option("MAIN", "MAIN", "font-family:Verdana;font-size:10px;");optionArray[63] = new Option("MANKATO", "MANKATO", "font-family:Verdana;font-size:10px;");optionArray[64] = new Option("MIL", "MIL", "font-family:Verdana;font-size:10px;");optionArray[65] = new Option("MIS", "MIS", "font-family:Verdana;font-size:10px;");optionArray[66] = new Option("PITT", "PITT", "font-family:Verdana;font-size:10px;");optionArray[67] = new Option("RECEIPT", "RECEIPT", "font-family:Verdana;font-size:10px;");optionArray[68] = new Option("ST5678", "ST5678", "font-family:Verdana;font-size:10px;");optionArray[69] = new Option("STP", "STP", "font-family:Verdana;font-size:10px;");optionArray[70] = new Option("STPETER", "STPETER", "font-family:Verdana;font-size:10px;");optionArray[71] = new Option("TENN", "TENN", "font-family:Verdana;font-size:10px;");optionArray[72] = new Option("TMP", "TMP", "font-family:Verdana;font-size:10px;");optionArray[73] = new Option("TMP2", "TMP2", "font-family:Verdana;font-size:10px;");optionArray[74] = new Option("TOR", "TOR", "font-family:Verdana;font-size:10px;");optionArray[75] = new Option("VAN", "VAN", "font-family:Verdana;font-size:10px;");optionArray[76] = new Option("VMI", "VMI", "font-family:Verdana;font-size:10px;");optionArray[77] = new Option("WNJ", "WNJ", "font-family:Verdana;font-size:10px;");writeSelectBox(optionArray, "filterSite1", 1, "document.frmDisplay.filterSite.value=this.options[this.selectedIndex].value", "font-family: verdana, arial, helvetica, sans-serif;font-size: 10px;vertical-align: middle;z-index: 0;width:97;");</script></td><td> </td><td><input align="left" size="10" name="filterMfr" value=""></td><td><input align="left" size="15" name="filterMFRPart" value=""></td><td> </td><td> </td><td><input type="hidden" name="filterSupplier"><script type="text/javascript">
var optionArray = new Array();
optionArray[0] = new Option(" - All - ", "", "font-family:Verdana;font-size:10px;");optionArray[1] = new Option("36", "36", "font-family:Verdana;font-size:10px;");optionArray[2] = new Option("41", "41", "font-family:Verdana;font-size:10px;");optionArray[3] = new Option("41.1", "41.1", "font-family:Verdana;font-size:10px;");optionArray[4] = new Option("AAAA", "AAAA", "font-family:Verdana;font-size:10px;");optionArray[5] = new Option("ACME", "ACME", "font-family:Verdana;font-size:10px;");optionArray[6] = new Option("ARGH", "ARGH", "font-family:Verdana;font-size:10px;");optionArray[7] = new Option("AVIMP1", "AVIMP1", "font-family:Verdana;font-size:10px;");optionArray[8] = new Option("AVNET", "AVNET", "font-family:Verdana;font-size:10px;");optionArray[9] = new Option("AVT", "AVT", "font-family:Verdana;font-size:10px;");optionArray[10] = new Option("BRADB3", "BRADB3", "font-family:Verdana;font-size:10px;");optionArray[11] = new Option("BRET", "BRET", "font-family:Verdana;font-size:10px;");optionArray[12] = new Option("DEL ME", "DEL ME", "font-family:Verdana;font-size:10px;");optionArray[13] = new Option("EBV", "EBV", "font-family:Verdana;font-size:10px;");optionArray[14] = new Option("EM1", "EM1", "font-family:Verdana;font-size:10px;");optionArray[15] = new Option("EM2", "EM2", "font-family:Verdana;font-size:10px;");optionArray[16] = new Option("GAEDKE", "GAEDKE", "font-family:Verdana;font-size:10px;");optionArray[17] = new Option("GPSI", "GPSI", "font-family:Verdana;font-size:10px;");optionArray[18] = new Option("HENRYT", "HENRYT", "font-family:Verdana;font-size:10px;");optionArray[19] = new Option("HEX", "HEX", "font-family:Verdana;font-size:10px;");optionArray[20] = new Option("IMS", "IMS", "font-family:Verdana;font-size:10px;");optionArray[21] = new Option("MILLER", "MILLER", "font-family:Verdana;font-size:10px;");optionArray[22] = new Option("PACKSP", "PACKSP", "font-family:Verdana;font-size:10px;");optionArray[23] = new Option("RIEMER", "RIEMER", "font-family:Verdana;font-size:10px;");optionArray[24] = new Option("ROARK", "ROARK", "font-family:Verdana;font-size:10px;");optionArray[25] = new Option("SCS", "SCS", "font-family:Verdana;font-size:10px;");optionArray[26] = new Option("SILICA", "SILICA", "font-family:Verdana;font-size:10px;");optionArray[27] = new Option("TIME", "TIME", "font-family:Verdana;font-size:10px;");optionArray[28] = new Option("WBC", "WBC", "font-family:Verdana;font-size:10px;");writeSelectBox(optionArray, "filterSupplier1", 1, "document.frmDisplay.filterSupplier.value=this.options[this.selectedIndex].value", "font-family: verdana, arial, helvetica, sans-serif;font-size: 10px;vertical-align: middle;z-index: 0;width:70");</script></td><td><input align="left" size="10" name="filterPO" value=""></td><td> </td><td><input align="left" size="12" name="fromDate" value="24-FEB-2014"><A HREF="#" name="ffromDate" id="ffromDate" onClick="cal1.select(document.frmDisplay.fromDate,'ffromDate','dd-MMM-yyyy'); return false;"><img src="images/calendar.gif" style="vertical-align: bottom; border: 0px;"></A>
to
<input align="left" size="12" name="toDate" value=""><A HREF="#" name="tfromDate" id="tfromDate" onClick="cal1.select(document.frmDisplay.toDate,'tfromDate','dd-MMM-yyyy'); return false;"><img src="images/calendar.gif" style="vertical-align: bottom; border: 0px;"></A></td><td><input align="left" size="12" name="fromDateLate" value=""><A HREF="#" name="ffromDateLate" id="ffromDateLate" onClick="cal1.select(document.frmDisplay.fromDateLate,'ffromDateLate','dd-MMM-yyyy'); return false;"><img src="images/calendar.gif" style="vertical-align: bottom; border: 0px;"></A>
to
<input align="left" size="12" name="toDateLate" value=""><A HREF="#" name="tfromDateLate" id="tfromDateLate" onClick="cal1.select(document.frmDisplay.toDateLate,'tfromDateLate','dd-MMM-yyyy'); return false;"><img src="images/calendar.gif" style="vertical-align: bottom; border: 0px;"></A></td><td><input align="left" size="10" name="filterUser" value=""></td><td><input align="left" size="10" name="filterBuyer" value=""></td><td><input align="left" size="10" name="filterNote" value=""></td><td nowrap="true"> </td><td nowrap="true"> </td><td nowrap="true"> </td><td nowrap="true"> </td><td nowrap="true"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr class="footerRow">
<td colspan="10"><a href="javascript:setChecked(1)">Check All</a> | <a href="javascript:setChecked(0)">Clear All</a></td>
</tr>
</table>
<table width="100%" valign="top" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<div class="nav">
<strong><font color="#db0055"><img width="15" src="images/shim.gif">Orders <input type="text" name="startRow" size="5" value="0">-0 of 0</font></strong>
</div>
</td>
</tr>
</table>
</form>
1 个解决方案
#1
1
Don't use .getAttribute('value')
. Use .value
instead.
不要使用.getAttribute('value')。请改用.value。
copyValue = document.getElementById('KanbanCopyNumber').value;
...
reportName = document.frmDisplay.rep.value;
The former will get you the value contained in the HTML. If the user updates the value of the field, the value
property will reflect that change, but the value
attribute will not.
前者将为您提供HTML中包含的值。如果用户更新字段的值,则value属性将反映该更改,但value属性不会。
#1
1
Don't use .getAttribute('value')
. Use .value
instead.
不要使用.getAttribute('value')。请改用.value。
copyValue = document.getElementById('KanbanCopyNumber').value;
...
reportName = document.frmDisplay.rep.value;
The former will get you the value contained in the HTML. If the user updates the value of the field, the value
property will reflect that change, but the value
attribute will not.
前者将为您提供HTML中包含的值。如果用户更新字段的值,则value属性将反映该更改,但value属性不会。