尝试在Bootstrap弹出窗口中添加链接(转到“帮助”页面)。看到了在弹出窗口中获取链接的各种复杂解决方案,但有人建议使用简单的onclick window.open。似乎是一个有趣的解决方案,但我在双/单引号地狱。

我正在使用phpStorm,它在突出显示错误方面做得很好。我正在尝试的是:

<i class="explain fa fa-question-circle text-primary"
data-toggle="popover" data-trigger="focus" tabindex="0" title="Popover title"
data-content="And here's some amazing content. It's very engaging.<a href='#'
onclick='window.open("http://www.google.com/");' title='test add link'>
link to content</a> Right?"></i>


这是我复制的原件:

<a href="#" onclick="window.open('http://www.google.com/');\"> link </a>


我的问题是,当我将单打切换为双打时,在"的初始("http://www.google.com/");处出现错误,并且标签未封闭。

我对这个电话不了解是什么。

最佳答案

尝试在HTML属性中使用“”:

<i class="explain fa fa-question-circle text-primary"
data-toggle="popover" data-trigger="focus" tabindex="0" title="Popover title"
data-content="And here's some amazing content. It's very engaging.<a href='#'
onclick=&quot;window.open('http://www.google.com/');&quot; title='test add link'>
link to content</a> Right?"></i>


在这里比较:How to properly escape quotes inside html attributes?

10-07 17:26