我的一位客户希望在他的网站上在新窗口中自动打开 pdf 文件的链接。
我已经编写了这段代码并且它有效:
$("a[target!='_blank'][href$='.pdf']").attr("target", "_blank");
我想知道是否还有其他好的解决方案?
最佳答案
要在网络浏览器的新选项卡中打开 .pdf,
$("a[target!='_blank'][href$='.pdf']").attr("target", "_blank");
要使用默认程序打开 .pdf,
$("a[target!='_system'][href$='.pdf']").attr("target", "_system");
关于javascript - 自动在新窗口中打开 pdf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27269710/