mooz Posted June 13, 2011 Share Posted June 13, 2011 Hi there, I am trying to automatically submit a form in an iframe with javascript. My question is whether this is possible or not, and if so how the code should look like to submit the form in the iframe? this is the form within the iframe that I am trying to submit automatically: <form style="clear: left; padding: 20px 5px 0 0" id="Form2051051" action="nieuw-bericht.2051051.lynkx" method="post" class="form" onsubmit="return ProcessForm( 'Form2051051' );"> <div> <a href="#" onclick="document.getElementById( 'event' ).value='Step1'; document.getElementById( 'Form2051051' ).submit(); return false;" class="button previous"><span>Wijzig</span></a> <a href="#" onclick="if ( ProcessForm( 'Form2051051' ) ) document.getElementById( 'Form2051051' ).submit(); return false;" class="button next-long"><span>Plaats bericht</span></a> </div> <input type="hidden" id="event" name="event" value="Confirmed-Step3" /> <input type="hidden" name="PostedField[_berichtId]" value="" /> <input type="hidden" name="formState" value="KQAAAAoAAAEAAgADAAQABQA9taWULZGFzZGFzIHNhZGEA" /> </form> this is what I have tried so far: <body LANGUAGE="javascript" onload="window.frames['myframe'].document.getElementById( 'Form2051051' ).submit();"> <iframe name="myframe" id="frame1" src="link-to-the-page-with-the-form"> </iframe> </body> I am pretty new with this so I appreciate any help or suggestions! thank you Quote Link to comment https://forums.phpfreaks.com/topic/239292-submitting-a-form-within-iframe/ Share on other sites More sharing options...
TrueColors Posted June 13, 2011 Share Posted June 13, 2011 I believe you'd need your JavaScript inside the page that the iFrame includes. Quote Link to comment https://forums.phpfreaks.com/topic/239292-submitting-a-form-within-iframe/#findComment-1229326 Share on other sites More sharing options...
mooz Posted June 14, 2011 Author Share Posted June 14, 2011 Hi, The webpage within the iframe is from an external website (im not in control of it). I did some more research and have read that it's not possible to use javascript on webpages in iframes that are not within my domain. Is this true? and if so is there any alternative to auto submit a button in an iframe? Quote Link to comment https://forums.phpfreaks.com/topic/239292-submitting-a-form-within-iframe/#findComment-1229352 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.