Function call in iframe in one domain, Internet Explorer support

I have an event on the parent page that fires a javascript function, which in turn calls another function on the child iframe. Both pages are in the same domain, and I confirmed this if a JavaScript document is displayed on both pages at the same time.

This is what has worked for years and is offered in similar topics: windows.frames ["iframeID"] SomeFunction (). This stopped working with Internet Explorer version 8.0.7600.16385. It works in Internet Explorer version 8.0.6001.18702

I tried to replace it with each of them, and the result was the same: iframeName.somefunction (); document.frames ("iframeName") SomeFunction () .; top.frames [0] .somefunction ();

The indicated error: "Access is denied" and refers to the first bit of code in somefunction (), however somefunction () works fine if called inside the iframe itself.

Is there a new “right” way to call functions inside an iframe from the parent? Is there a workaround on the code side (I cannot control the user's browser)?

EDIT: here is the internal function: somefunction () {somebutton.click (); } If instead I use "alert (" something ");", it works without errors.

EDIT2: The newer version as well as IE9 Beta expanded it to also defeat the hacker workaround, so I returned to death in the water.

EDIT3: I forgot about it until someone posted almost a year later. This is the workaround I came across:

iframename.badscripthack(); iframe : badscripthack() {  document.getElementById( "OffscreenTextField" ) (). } submitthis() {  document.getElementById( "SubmitButton" ) (). } :

, , . , "" . , "", ( , ).

+3
1

HTML

<html>
<head>
 <script type="text/javascript">
  function CallFrame()
  {
        var frame = document.getElementById("myframe");
    if(frame)
    {
           frame.contentWindow.Show();
        }
  } 
</script>
</head>
<body>
<h1> I am Parent </h1>
<input type="button" onclick="CallFrame()" value="Call Frame function" /><br/>
<iframe id="myframe" src="Frame.html" />
</body>
</html>

Frame.Html

<html>
<head>
<script type="text/javascript">
function Show()
{
alert("Called");
}
</script>
</head>

<h1> I am IFrame</h1>
<input type="button" onclick="Show();" value="Call Own function">
</body>
</html>

FireFox IE8

+1

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


All Articles