简体   繁体   English

iframe模式无法关闭

[英]iframe modal failing to close

I use an iframe modal, spawned from a browser bookmarklet, to gather information from a web page a user is looking at. 我使用从浏览器小书签生成的iframe模式,从用户正在查看的网页上收集信息。

The code, which a user adds to their bookmarks toolbar which fires the bookmarklet when clicked is this: 用户添加到其书签工具栏的代码,该代码在单击时会触发小书签。

javascript:(function(d){var%20modal=document.createElement('iframe');modal.setAttribute('src','http://9ammusic.com/test/bookmarklet.html?url='+encodeURIComponent(window.location.href)+'&page_title='+document.title);modal.setAttribute('scrolling','no');modal.className='modal';document.body.appendChild(modal);var c=document.createElement('link');c.type='text/css';c.rel='stylesheet';c.href='//9ammusic.com/css/iframe.css';document.body.appendChild(c);}(document));

this code works by the way to show the problem 该代码通过显示问题的方式起作用

95 times out of 100 this works fine and it closes as it should, but sometimes, the close link simply does not work - is there a different/better way I can close a modal such as this? 100的95倍可以正常工作,并且可以正常关闭,但是有时候,close链接根本不起作用-是否有其他/更好的方法可以关闭这种模式?

to test please go to link below and try the bookmarklet - it closes fine in Firefox but doesn't close in Chrome: 要进行测试,请转到下面的链接并尝试使用书签-在Firefox中可以正常关闭,但在Chrome中无法关闭:

http://www.ebay.co.uk/itm/JEFF-BANKS-BESPOKE-BLACK-RED-PINSTRIPE-100-WOOL-MENS-SUIT-36S-DRY-CLEANED-/330789478348?_trksid=p5197.m1992&_trkparms=aid%3D111000%26algo%3DREC.CURRENT%26ao%3D1%26asc%3D14%26meid%3D1848697403629550114%26pid%3D100015%26prg%3D1006%26rk%3D1%26#ht_1830wt_1163

This works for some reason so all good for now, using a form instead of a link: 出于某种原因,这有效,使用表格而不是链接,对目前来说都很好:

<form method=post action=<?=$_GET['url']?> target="_parent">
<input type=submit value="X Close Window"></form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM