简体   繁体   中英

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.

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?

to test please go to link below and try the bookmarklet - it closes fine in Firefox but doesn't close in 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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