iframe

How to find selection in HTML document that contains iframe or just frames

99封情书 提交于 2019-12-18 13:37:38
问题 Is there a way to find the selected text in an HTML document if the text may be within one of its frames (or iframes)? If the document has no frames it's simple: var text; if (document.getSelection) { // Firefox and friends text = document.getSelection(); } else if (document.selection) { // IE text = document.selection.createRange(); } if (text == undefined || text == '') { // Iterate over all textarea elements and see if one of them has selection var areas = document.getElementsByTagName(

Why doesn't IE8 handle iframe onload events?

青春壹個敷衍的年華 提交于 2019-12-18 13:31:18
问题 Sample code: <!DOCTYPE html> <html> <head> <title></title> <script> function on_iframe_load() { document.getElementById('iframe_a').onload = function() { alert('Thanks for the visit!'); }; } </script> </head> <body> <iframe name="iframe_a" id="iframe_a"></iframe> <a href="http://www.example.com/" target="iframe_a" onclick="on_iframe_load();">Go!</a> </body> </html> It works in all major browsers with no problem, but IE8 (and probably prior versions) don't understand it. Update : Just came up

Want to call a function if iframe doesn't load or load's?

我与影子孤独终老i 提交于 2019-12-18 13:28:37
问题 I have a iframe in my page. If the iframe doesn't load, want it to alert the message " pdf not found " and if the iframe does load, it should alert " pdf opened ". Does anyone know how to achieve that? 回答1: So, the idea is to use an Ajax-request to "test" the URL. Ajax-requests enable you to bind "success" and "error" handlers - unlike <iframe> elements which only provide a "load" handler. Of course, Ajax-requests are restricted by the Same Origin Policy (unless the web-server enables CORS),

Change background color of iframe issue

家住魔仙堡 提交于 2019-12-18 13:25:22
问题 I need to change background color to white of the displayed page if <iframe></iframe> . Is that possible? Now background of the original website is gray. <iframe allowtransparency="true" style="background-color: Snow;" src="http://zingaya.com/widget/9d043c064dc241068881f045f9d8c151" frameborder="0" height="184" width="100%"> </iframe> I want to change the background of loaded page 回答1: I frame background can be changed. like below <iframe allowtransparency="true" style="background: #FFFFFF;"

How do I get all iframe elements?

冷暖自知 提交于 2019-12-18 12:59:08
问题 I'm showing a loading indicator while some external iframes are loaded with the following code: <html> <head> <title>Loading iframe</title> </head> <script> function loading_iframe(){ document.getElementById('loading_iframe').style.display = "none"; document.getElementById('loading').style.display = ""; document.getElementById('loading_iframe').onload = function(){ document.getElementById('loading').style.display = "none"; document.getElementById('loading_iframe').style.display = ""; } } <

Determine if an element in an iframe is visible on the screen

孤街醉人 提交于 2019-12-18 12:34:26
问题 I need to determine if an element in an iframe is visible on the screen. (if it is on the visible part of the screen) I mean the page can be very long and user must scroll to see the element index.html: <html> ... ... <iframe src="iframe.html" /> ... ... </html> iframe.html: <html> ... ... <div id="element"></div> .... ... <script type="text/javascript"> var el = document.getElementById('element'); if (isElementVisible(el)) { // do something } </script> </html> How to write such a function

Is it possible to “fake” the src attribute of an iframe?

£可爱£侵袭症+ 提交于 2019-12-18 12:27:36
问题 I try to add dynamically an iframe to a web page using JavaScript. I would like to know if that's possible to set the src attribute of my iframe without using another html file via an URL. I mean is there a way to "fake" the html for the src attribute file with a JS variable where we I can set my code (which is JS itself) ? I would use the DOM createElement to create the iframe in jQuery. Thanks ! 回答1: You could look into data:URIs. <iframe src="data:text/html, .... URLencoded HTML data ...."

How to post data to iframe with Jquery

醉酒当歌 提交于 2019-12-18 12:26:22
问题 How can I dynamically post data to an iframe in Jquery. I really need to post data to an Iframe in this case, I cannot use a $.POST because data received is returned sequentially (buffered) If you have a workaround to make jquery handle data returned by a $.POST 'when it receives the data. I'm very curious! At the moment I handle it with GETS this way: var iframe = $('<iframe style="display:none;"></iframe>'); $( "body" ).append(iframe); iframe.attr('src','server.php?type=getFolders&inode='

Detect <iframe> height and width from inside the iframe

▼魔方 西西 提交于 2019-12-18 12:26:06
问题 I doubt this is actually possible but Im prepared to be corrected. What I need is to be able to detect the width and height of an iframe from within the iframe, so if the iframe src is iframeContent.html I need to be able to surface the values on this page. I have no control over the page that hosts the iframe only the contents of the iframe. Is this possible? 回答1: You can always get the web page dimensions, no matter if the page is loaded inside an iframe or a new window it always works the

iframe on iOS (iPad) content cropping issue

狂风中的少年 提交于 2019-12-18 11:47:09
问题 I'm looking for the correct way to assure that dynamically revealed content is visible after scrolling in an iframe on ipad / iOS5. Oh Iframes and iPad - what a wonderful old chesnut you are. I know that: iPad expands iframes to the full height of the content within it (almost like it was using HTML5's "seamless" property, but not quite since it doesn't inherit styles or events from the parent). Bizarre, annoying to many, but true. <iframe height="100%"> is therefore useless since it sizes to