DOC Javascript 函数: function getPolicyPaper-6ren">
gpt4 book ai didi

javascript - 具有 Javascript 功能的 Href 右键单击​​时不显示 "Save Target as"

转载 作者:行者123 更新时间:2023-12-03 09:47:09 25 4
gpt4 key购买 nike

下面是我的 jsp 页面上的链接:

<td  height="37" align="right">
<a href="javascript:getPolicyPaper('/cpi/producer/CSPDocumentGateway?jadeAction=MCS02&<%= MCSUIKeys.ASP_MCS_DOCUMENT_SELECTED %>=<%= i %>&m=<%=aView.getCalMonth()%>&y=<%=aView.getCalYear()%>&p=<%=aView.getProducerNumber()%>', 'pdf', '640','550')">DOC</a>
</td>

Javascript 函数:

function getPolicyPaper(policyPaperUrl,policyType,windowWidth,windowHeight) {
//Calculate center of screen
var winWidth = windowWidth;
var winHeight = windowHeight;
var policyElement = policyType;
var xPos = (screen.availWidth-winWidth)/2;
var yPos = (screen.availHeight-winHeight)/2;
attrib = "hotkeys=true,menubar=no,personalbar=no,titlebar=yes,toolbar=no,location=no,top=" + yPos + ",left=" + xPos + ",width=" + winWidth + ",height=" + winHeight +",resizable=yes,scrollbars=no";
new_window= window.open(policyPaperUrl, policyElement, attrib);
new_window.focus();

}

当我在 IE8 中右键单击“DOC”链接时,它现在会显示“目标另存为”选项。我需要为用户提供右键单击并保存此 pdf 文档的选项。

最佳答案

您可以将 URL 格式化为:

 <a href="/cpi/producer/CSPDocumentGateway?jadeAction=MCS02&<%= MCSUIKeys.ASP_MCS_DOCUMENT_SELECTED %>=<%= i %>&m=<%=aView.getCalMonth()%>&y=<%=aView.getCalYear()%>&p=<%=aView.getProducerNumber()%>' onclick="getPolicyPaper(this.href, 'pdf', '640','550'); return false;">DOC</a>

更好的方法是将 JS 处理程序移至事件监听器中。

关于javascript - 具有 Javascript 功能的 Href 右键单击​​时不显示 "Save Target as",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30987189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com