<!-- 1.1,使用Javascript来折叠和展开页面某区域 -->
<input type="button" name="folderButton" id="folderButton" value="折叠/展开"
οnclick="var folderArea=document.getElementById('folderAreaId');
if (folderArea.style.display=='none') {
folderArea.style.dispaly='block';
} else if (folderArea.style.display=='block') {
folderArea.style.dispaly='none';
}"
/>
<br/>
<div id="folderAreaId" style="display:none">
There is some information that contains text, picture and so on.
</div>
<!-- 1.2,使用Javascript来折叠和展开页面某区域 -->
<img id="collapse" name="collapse" class="imgexpandcollapse" src="wt/clients/images/collapse.gif"
οnclick="
var span = document.getElementById('folderAreaId');
var visiblestr = 'visible';
var imgsrc = this.src;
if(imgsrc.indexOf('collapse.gif') != -1) {
imgsrc = 'wt/clients/images/expand.gif';
span.style.display = 'none';
visiblestr = 'hidden';
} else if(imgsrc.indexOf('expand.gif') != -1) {
imgsrc = 'wt/clients/images/collapse.gif';
span.style.display = '';
visiblestr = 'visible';
}
this.src = imgsrc;"/>"
<!-- 2,使用Javascript获取当前页面URL中的参数并调用其它JSP页面 -->
<!-- encodeURI(..): 将变量的字符编码转换为UTF-8格式 -->
<input type="button" name="export" class="wizBtn" value="Export BOM"
οnclick="javascript:doExport();"/>
<script language="javascript">
function doExport(){
var requestParamStr = window.location.search;
var aparam = requestParamStr.split("&");
var oid = null;
for (var i = 0; i < aparam.length; i++) {
if (aparam[i].indexOf("oid=") != -1) {
oid = aparam[i];
break;
}
}
if (oid == null) {
alert("[ERROR:] oid is null.");
} else {
var url = getBaseHref() +
"netmarkets/jsp/ext/com/jwis/bom/exportBOM_toExcel.jsp?" + encodeURI(oid);
popupAction('BeginExport', url, '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', 'height=200, width=400',
'', '', false, '', false, '', false, '');
}
}
</script>
<!-- 3,使用Javascript刷新页面中的表格内容 -->
function refreshTable (var tableId) {
var agent = navigator.userAgent.toLowerCase();
var isIE = (agent.indexOf("msie") != -1);
refreshCurrentElement(tableId, false, ieIE);
}
<!-- 4,使用Javascript将页面的指定区域导出到本地Excel文件中 -->
<input type="button" value="Sava as excle.." οnclick="savaAsExcel()"/>
function savaAsExcel() {
var window_new = window.open('', '_blank', 'top=10000');
var strHTML = document.getElementById("areaID").innerHTML;
// 或者 var strHTML = document.all.areaID.innerHTML;
window_new.document.open('text/html', 'replace');
window_new.document.writeln(strHTML);
window_new.document.execCommand('saveas', '', 'export_excel.xls');
window_new.close();
}
<div id="areaID">
<table></table>
</div>
JS eg.
最新推荐文章于 2024-04-19 09:41:10 发布