如何解决有人可以帮我修复 html 链接吗
嘿,我需要有关此代码的帮助,我希望该链接在新选项卡中打开 我希望链接在新标签页中打开,而不是在当前标签页中打开
<form>
<input class="MyButton" type="button" value="Your Text Here" onclick="window.location.href='http://www.yourdomain.com'" />
</form>
解决方法
为了定位新窗口,您需要使用 target="" property
window.location.href
还包含当前网址的链接。
<form>
<input class="MyButton" type="button" value="Your Text Here" onclick="window.location='http://www.yourdomain.com'" target="_blank"/>
</form>
,
如果您想使用 Javascript,请使用:WINDOW.OPEN
<form>
<input class="MyButton" type="button" value="Your Text Here" onclick="window.open('http://www.yourdomain.com')" />
</form>
,
要在新标签页中打开链接,您必须添加 target="_blank"
像这样
<form>
<input class="MyButton" type="button" target="_blank" value="Your Text Here" onclick="window.location.href='http://www.yourdomain.com'" />
</form>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。