Submitting a form from one iframe to another - IE

This seems to be an old problem. But I can not find a solution.

I have a page with two iframes. They load as such:

<iframe id="leftIframe" src="predict_goalkeepers.php" height="900" width="300" frameBorder="0" hspace="0"></iframe> <iframe id="rightIframe" src="predict_right.php" height="900" width="300" frameBorder="0" hspace="0"></iframe> 

Then I want to publish something from leftIframe to the right and update leftIframe at the same time. I did this using the target frame and the onclick function. On the left side of the window there is the following:

 <form action="predict_rightframe.php" method="post" name="form1" id="form1" target="rightIframe"><input type="checkbox" name="goalkeepers" value="1" onclick="this.form.submit(); window.location.reload(true)"> 

This works fine and is super duper in Chrome. But when checking on Firefox and IE, the frame opens in a new window.

Anyway?

I believe that there is a “hack” thanks to which you can get javascript to create a frame. But only the advice I found is to create a hidden frame ( see here ) But I want this frame to be visible.

Any help on this issue would be extremely helpful - even if it just adapts the above javascript code to create a visible iframe.

+4
source share
1 answer

I fixed it! It took hours of my time.

But if someone has the same problem. Here is the solution ..

Create a file called frame.js with the data:

  var filePath = 'predict_rightframe.php'; // Setup the iframe target var iframe='<iframe id="myIframe" name="myIframe" src ="predict_rightframe.php" width="300" height="450" marginheight="0" marginwidth="0" frameborder="no" scrolling="no"></iframe>'; // Write the iframe to the page document.write(iframe); var myIframe = parent.document.getElementById("frame"); // Setup the width and height myIframe.height = 450; myIframe.width = 300; myIframe.src = filePath; // set the style of the iframe myIframe.style.border = "0px solid #999"; myIframe.style.padding = "0px"; 

Then, where you want the iframe to appear just in time:

 <script language="JavaScript" src="includes/frame.js"></script> 

I'm not too sure why this works (to be honest, I don't care because it works!). This has something to do with the fact that IE does not think that the iframe is an object. Javascript can make IE think it's an object ... well, it works anyway now.

0
source

Source: https://habr.com/ru/post/1432659/


All Articles