这是最好的方法。使用按钮打开链接
<button type="button" onclick="location='permalink.php'">Permalink</button>
<button type="button" href="index.php">Permalink</button>
如果你使用jquery,你可以像这样编写第二个按钮
<button type="button" id="SecondButton" data-href="index.php">Permalink</button>
然后添加一些 JavaScript:
<script type="text/javascript">
$('#SecondButton').click(function(e) {
e.preventDefault(); e.stopPropagation();
window.location.href = $(e.currentTarget).data().href;
});
</script>
编辑(进一步完成的场景)
<button type="button" id="SecondButton" data-href="index.php" onclick="location='permalink.php'" href="index.php">Permalink</button>
我也会在其中插入额外的 href 标签和 onclick ;然后你可以测试不同的场景;不支持 javascript 或 jquery 的设备无法在 CDN 上加载,例如移动设备等:
<button type="button" id="SecondButton" data-href="index.php?trackAnalytics=1" onclick="location='permalink.php?trackAnalytics=2'" href="index.php?trackAnalytics=3">Permalink</button>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)