将HREF放入OnClick活动
我有一个页面,其中包含指向多个PDF的不同链接。链接是动态创建的,因此我无法直接编辑HTML。
<a href="https://example.com/presentation-1.pdf" target="_blank">Download</a>
<a href="https://example.com/presentation-2.pdf" target="_blank">Download</a>
我正在尝试打开指向新窗口中PDF的每个链接。 这就是我到目前为止得到的:
$("a[href$='.pdf']").attr("onclick", 'https://example.com','popup','width=600,height=600'); return false;");
当然,新窗口必须包含PDF。因此, https://example.com 代码中应包含正确的PDF的HREF。谁能帮我吗?
I have a page containing different links pointing to several PDF's. The links are dynamically created so I can't edit the HTML directly.
<a href="https://example.com/presentation-1.pdf" target="_blank">Download</a>
<a href="https://example.com/presentation-2.pdf" target="_blank">Download</a>
I'm trying to open every link that points to a pdf in a new window.
This is what I got so far:
$("a[href$='.pdf']").attr("onclick", 'https://example.com','popup','width=600,height=600'); return false;");
Ofcourse the new window has to contain the pdf. So the https://example.com in the code should contain the href of the correct PDF. Can anyone help me out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
注意 - 新窗口不会在此处打开,因为该请求是在未设置“允许popups”权限的沙盒框架中提出的。
Note - New window will not open here because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.