Posts

Showing posts with the label Iframe

Apply A Greasemonkey/Tampermonkey/userscript To An Iframe?

Answer : In Greasemonkey (And Tampermonkey and most userscript engines) a script will fire on an iframe automatically if it meets the @include, @exclude, and/or @match directives. And, a popular question is how to stop Greasemonkey from firing on iframes. So, if your script had a match like: @match https://fiddle.jshell.net/* It would fire on jsFiddle "output" pages whether or not they appeared in an iframe. If you wanted to fire on a JUST iframed content: Then you would check the window.self property. For example, suppose you had a target page like: <body> <h1>I'm some webpage, either same-domain or not.</h1> <iframe src="//domain_B.com/somePath/somePage.htm"> ... Then you could use a script like: // ==UserScript== // @name _Fires specially on domain_B.com iframes // @match *://domain_B.com/somePath/* // ==/UserScript== if (window.top === window.self) { //--- Script is on domain_B.com when/if it is the M...

An Iframe I Need To Refresh Every 30 Seconds (but Not The Whole Page)

Answer : You can put a meta refresh Tag in the irc_online.php <meta http-equiv="refresh" content="30"> OR you can use Javascript with setInterval to refresh the src of the Source... <script> window.setInterval("reloadIFrame();", 30000); function reloadIFrame() { document.frames["frameNameHere"].location.reload(); } </script> Let's assume that your iframe id= myIframe here is the code: <script> window.setInterval("reloadIFrame();", 30000); function reloadIFrame() { document.getElementById("myIframe").src="YOUR_PAGE_URL_HERE"; } </script> Okay... so i know that i'm answering to a decade question, but wanted to add something! I wanted to add a google calendar with special iframe parameters. Problem is that the calendar didn't work without it. 30 seconds is a bit short for my use, so i changed that in my own file to 15 minutes This worked for me. <script...

Access Parent URL From Iframe

Answer : Yes, accessing parent page's URL is not allowed if the iframe and the main page are not in the same (sub)domain. However, if you just need the URL of the main page (i.e. the browser URL), you can try this: var url = (window.location != window.parent.location) ? document.referrer : document.location.href; Note: window.parent.location is allowed; it avoids the security error in the OP, which is caused by accessing the href property: window.parent.location.href causes "Blocked a frame with origin..." document.referrer refers to "the URI of the page that linked to this page." This may not return the containing document if some other source is what determined the iframe location, for example: Container iframe @ Domain 1 Sends child iframe to Domain 2 But in the child iframe... Domain 2 redirects to Domain 3 (i.e. for authentication, maybe SAML), and then Domain 3 directs back to Domain 2 (i.e. via form submissi...

Access Parent Window From Iframe (cross-domain)

Answer : If I were you I would check out window.postMessage. It may do what you want: For reference see the following: MDN - Window.postMessage https://stackoverflow.com/a/3076648/296889 - see the Window.postMessage section If I understand correctly, all modern browsers do now allow to do this. So I'm here to find the best solution. This is your solution. What you're asking is not possible. See related questions: How to access parent Iframe from JavaScript <iframe> javascript access parent DOM across domains? Cross-domain access in iframe from child to parent EDIT As mentioned in the comments below, @JeremysAwesome's answer offers a method that would allow cross-domain requests under certain circumstances. See the SO question below for more information. Ways to circumvent the same-origin policy but you can change the src attribute of the iframe (adding a #hashtag for example) and listen to the onhashchange event in the child window...

Catch Error If Iframe Src Fails To Load . Error :-"Refused To Display 'http://www.google.co.in/' In A Frame.."

Answer : You wont be able to do this from the client side because of the Same Origin Policy set by the browsers. You wont be able to get much information from the iFrame other than basic properties like its width and height. Also, google sets in its response header an 'X-Frame-Options' of SAMEORIGIN. Even if you did an ajax call to google you wont be able to inspect the response because the browser enforcing Same Origin Policy. So, the only option is to make the request from your server to see if you can display the site in your IFrame. So, on your server.. your web app would make a request to www.google.com and then inspect the response to see if it has a header argument of X-Frame-Options. If it does exist then you know the IFrame will error. I think that you can bind the load event of the iframe, the event fires when the iframe content is fully loaded. At the same time you can start a setTimeout, if the iFrame is loaded clear the timeout alternatively let th...

Chrome Vimeo Iframe Autoplay Not Working Anymore

Image
Answer : Annotating the <iframe> with an allow attribute worked for me: <iframe ... allow="autoplay; fullscreen"></iframe> It's called "Iframe delegation" and is described here: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes. You need to add &muted=1 to the iFrame src path and you need to add the attribute allow="autoplay" to the iFrame. Now the Vimeo video starts automatically again in Chrome. yes, according to their documentation it is. https://help.vimeo.com/hc/en-us/articles/115004485728-Autoplaying-and-looping-embedded-videos EDIT: Advance browsers like FireFox, Chrome and Safari are now blocking video autoplay by default. CHROME Auto-Play Policy: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes The Media Engagement Index, or MEI for short, a way of Chrome is to allow AutoPlay audio on your page to be based on your previous interactions with thi...