html - 如何使按钮 onclick 动作在新窗口中打开?
问题描述
我试图创建一个链接到在新窗口中打开的 PDF 文件的按钮。尝试了 _blank 方法,但没有奏效。
<button onClick="parent.location='files/sample.pdf'" class="send" >Curriculum vitae</button>
</form>
解决方案
您可以使用锚标记并为其设置样式
<a class="btn btn-success" href="https://www.google.com" target="_blank">Google</a>
或者您可以将按钮更改为
<button title="button title" class="action primary tocart" onclick=" window.open('http://www.google.com', '_blank'); return false;">Google</button>
推荐阅读
- sql - 在日期格式不同的日期连接两个表 DB2
- python - cv2.resize 与 Python :插值方法到底是什么?
- syntax - 如何部分初始化 ArrayVec?
- amazon-web-services - 如何在 AWS Step Function 中从 Choice 状态传递不同的输出?
- javascript - 匹配地址的正则表达式的一部分
- regex - 使用 Where 对象匹配数组列表
- nativescript - 如何从分叉的存储库安装 NativeScript 插件?
- scala - 如何确保janusgraph中只添加一项
- css - Sass 错误:“...0, 0, -5deg); }”之后的 CSS 无效:预期 1 个选择器或规则,为“{”
- sql - 是否有任何替代自我加入的方法