I have an IFrame with an external content which i can't modify because of Same-origin policy
My problem is i want to avoid visitors viewing the iframe-content out of the context of the main page (e.g. because they followed a link in search-results) but i have no control of it !
When people click a link or something in the page, it is open in a new tab and not inside the iframe ! All i want is a full embedded browser.
How can i avoid this if i don't have control of the iframe content ? I can see the html with the "inspect element" function of the browser but i cannot do it with javascript because of Same-Origin-Policy.
Related
I have added an iframe to my webpage that is used for converting video links to mp3 format.
iframe shows a button that, when clicked, opens a new tab before starting to download the wanted mp3 file. I would like to know if there is a way in javascript to close that newly opened tab to ensure a better user experience. I know that window.close() can do that, but not sure if we can apply that to a tab opened by a script from an iframe.
This is the iframe in question, It sends a get request to the link specified in the src attribute.
<iframe id="downloadIframe" src="https://loader.to/api/button/?url=${vidLink}&f=mp3&color=0964D3"></iframe>
When the iframe is loaded, you can see this in the code it loads with it:
<a id="downloadButton" onclick="onClick();window.open('https://loader.to/ajax/a.php');" href="#">
I believe that the opened window is caused by window.open().
Knowing that I cant change the code that is within an iframe, any idea how I can close that tab?
Open the dowlnoad in a iframe instead of a tab.
Then you can later drop the iframe from the DOM making it disappear.
you can block the iframe from opening new tabs by using the sandbox attribute.
sandbox=""
Sandbox Applies extra restrictions to the content in the frame. The value of the attribute can either be empty to apply all restrictions or space-separated tokens to lift particular restrictions.
You can read more about it here
I have a wordpress website, where I have pages with artists. This is an example: http://chasefetti.paradigmrecordsinc.com/ of a page from my website
On the top I have an iframe from arena.com
I want after the page loads to click the play button.
If I do it on the arenas page http://arena.com/artist/chasefetti like this (using firebug):
document.getElementsByClassName("fg icon-play-fg")[0].click()
it works, but on my website I guess it doesn't know about accessing the iframe.
How can I specify to access that iframe ?
Also the full mission that I gotta do is to play that button for each page. I am thinking to add a jquery that does what I want to do, to the templates page.
My main problem is accessing that element from the iframe
As far as I know(I tired it once) you can't do that, unless the source of the iframe is on the same site as yours, which isn't the case here.
Also check this same-origin policy.
I am working on an app where I have a flash app that access a URL through an iFrame. The contents of the iFrame is 3rd party content. The content is a menu that you can navigate through but once you get to a certain point, the menu launches a pop up, and the popup is the continuation of the menu.
I was wondering if there is anyway that I could capture the popup and make it load within the parent/opener page, using jQuery perhaps to change the contents of the iframe?
This solution is probably way out there but I was just hoping for a nice quick fix.
The reason that this is a problem is that the app is for a tablet and the popup doesn't appear within an app on the tablet.
Thanks
If the iFrame content is served from a different domain than the parent/owner document, you're out of luck - that is, if you have no control over the iframe content. This is due to JavaScript's same origin policy.
If you are able to modify the web app running inside the iframe, you could try using window.postMessage (HTML5) to notify the parent window.
I have my html where I embed third-party flash video by means of iframe. When I click play on the video a popup is opened.
I was wondering id there is a way to add a javascript function to my html that would close such a popup immediately when it is opened?
No I'm afraid not. The popup window belongs to the iframe, which as you explained is third party content and thus on a different domain to the host site.
Security restrictions prevent javascript from actiong on windows or documents across domains. This is called the Same Origin Policy.
I want to open a remote url inside a javascript popup instead of doing window.open().
I came across libraries like lytebox,lightbox,thickbox which do that if the popup is opened from main webpage.
However my requirement is to open the popup from the link which occurs in a small iframe within the main page.( I can not alter the code of the main page, however Iframe webpage is fully in my control)
When I include those libraries in my iframe webpage, it opens the popup, but restricted only
to within iframe.How to make it appear over whole browser window ?
This is what i want : The user clicks on "click here" and it opens a javascript layer,not
restricted to within iframe.
you can just use
parent.document
from the iframe to access the parent window, if it is from the same domain. Otherwise, security concerns are raised.
You can inject the javascript by creating a script element in the parent's document, and then will be able to access the necessary functions.