我的网站上有一些产品页面,上面有一个iframe。iframe的存在扰乱了浏览器的历史记录-当前页面被添加到历史记录堆栈中,当我单击“上一步”按钮时,页面保持不变,我必须单击两次才能进入实际的上一页(我必须快速单击,否则页面将再次添加到堆栈中)。我把这个问题隔离开来,因为当我删除整个iframe时,问题就消失了;当我删除
src
<iframe sandbox="allow-same-origin allow-scripts" class="add-to-cart__iframe" id="addtocartiframe" src="https://buy.website.com/en/addtocart/#/addToCart/109ATCA714-1003R/71cbba730b634200ac437cc3907ed626/en" title="Add to Cart"></iframe>
我试着加上
sandbox="allow-same-origin allow-scripts"
基于
How can I prevent Iframe messing browser's history after interactions with it?