I use a third party iframe src, and I want to submit my form when the Iframe src change...
how to trigger the submit button when the inner Iframe source change?
how to trigger the submit button when the inner Iframe source change?
You can't access iframe content if it belongs to different domain.
I use a third party iframe src
So defenitly not as its other domain
Also from w3school
Note: Because of security reasons, the contents of a document can be accessed from another document only if the two documents are located in the same domain.
I changed the redirected page and add on it
<body onload="parent.parent.send()">
On the main page (where the iframe located) I add:
<script>
function send()
{
document.getElementById("gform_1").submit();
}
</script>
It solve my problem.
Related
I have a same domain page loaded inside an iframe (using sandbox attribute). I use the following code to prevent clicks (and all other elements) from navigating away form the page:
$('#preview_frame').contents().find('body *').off('click').click(
function(event){
event.stopPropagation();
event.preventDefault();
}
);
However it seems that other Javascript on the page is redirecting the navigation via window.location.href or window.location.replace.
I cannot change the code of the pages inside the iframe as they are proxied from other sites.
I tried using the iframe unload event without success.
I need to disable the ability to navigate inside the iframe no matter what/how it is done. I am not talking about top parent navigation which can be disabled with the sandbox attribute, I am talking about the navigation INSIDE the iframe itself.
Is it possible to accomplish that?
Your code seems correct. Remove the sandbox attribute if the page inside iframe is from same domain. Hope it will solve the problem.
Sandbox attribute always treats contents as unique origin.
I am working on a payment website, which needs to integrate a 3rd party website inside an iframe. However, at some point, the user can click a button inside the iframe, which redirects the parent window to another URL.
I cannot touch the 3rd party code.
Is it possible to capture this URL the parent window is being redirected to, stop this redirection, and pop up another window for that URL?
Thanks for any help.
You will be able to detect when the iframe's url changes, but you will not be able to look at what the new url is. That may be just enough. If the user clicks something in the iframe, and the iframe changes url, then you can detect that and redirect the parent window.
Plain javascript solution:
<iframe
src="https://target.com/page"
onload="alert('iframe has loaded or changed')">
</iframe>
jQuery solution:
<iframe class="target-iframe" src="https://target.com/page"></iframe>
$(document).on('load', '.target-iframe', function () {
alert('iframe has loaded or changed')
});
I'm using wix to create simple landing page and would like to connect it with google analytics events.
I would like to intercept the event of pushing form send button.
Page example with form
The button id -> submitButton
Normally if i have full access to page code i use:
<script type="text/javascript">
$(document).ready(function () {
$('#buttonName').click(function () {
//google function
ga('send', 'event', 'EventCategory', 'EventCategory', 'EventName');
});
});
</script>
But here I can use only iFrame an internal plugin (hat generate code inside iframe).
PAGE STRUCTURE:
- Text, image ecc ecc;
- iFrame with form (managed by plugin, where i can't add/edit code);
- iFrame where i can add code. for example: example page
So I need to invoke click event of the button with id submitButton from an iframe which invokes the click of the button placed in other iframe (where the id is unknown).
is there a way to do that?
Thank you for response.
If you do not have access to the iFrame code you will not be able to put that tracking id the way you want.
If you're trying to intercept a click event within the iframe that you don't have control of, I'm pretty sure that's not possible for security reasons: otherwise it would be possible for an advert or any third party code on your page to intercept events on completely unrelated elements.
If you're trying to pass a click event from a bit you do control to a button that you don't, unless you know the ID of the button in the other iFrame you want to click, I don't think you're going to have much luck.
I need to submit a form which is loaded inside a iframe.
But this src will be loaded from different domain from its parent page.
I have tried Window.postMessage which can communicate to inner iframe but I doubt for cross domain page also for which we cant have to source control we can't add listener to that page.
So, Any help on this for iframe cross browser site communication without any code added on the iframe page.
I have 2 <iframe> on my main HTML form.
These <iframe> are loaded from different external domains. Sometime external server goes offline and user see The page can't be dispayed message on my page.
Is there a way to hide these <iframe> when target server is not available?
You can use onload event to display iframe content. Make iframe invisible by default and set visible in onload event,
You could set up a listener for the load event and if this isn't called within a certain timespan then you hide the frame..