html – 在iframe srcdoc值中转义引号

根据 spec的报价必须转义,即代替:
<iframe seamless sandBox srcdoc="<p>Yeah,you can see it <a href="/gallery?mode=cover&amp;page=1">in my gallery</a>."></iframe>

我们应该使用:

<iframe seamless sandBox srcdoc="<p>Yeah,you can see it <a href=&quot;/gallery?mode=cover&amp;amp;page=1&quot;>in my gallery</a>."></iframe>

但是在上面的例子中简单地使用单引号是不行的:

<iframe seamless sandBox srcdoc="<p>Yeah,you can see it <a href='/gallery?mode=cover&amp;page=1'>in my gallery</a>."></iframe>

解决方法

链接的规范仅注意到引号被转义,因为

otherwise the srcdoc attribute would end prematurely.

使用单引号没有问题,如上一个例子所示.

如果价值中有单引号(例如,“你是”),那么你必须逃避任何一个或另一个.

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些