Re: XP SP2 cross-iframe scripting

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dave Methvin (news0110_at_methvin.com)
Date: 09/17/04


Date: Fri, 17 Sep 2004 13:21:09 -0400

Here's something that may affect it as well. In XP SP2 the scripting engine
will invalidate any objects within an element that you reprocess by a
document.write, using EditMode, or by changing .src attributes. So, trying
to use myframe after setting theFrame.src would cause an error unless you
re-assigned the object:

var myframe = theFrame.document;
theFrame.src = "whatever.htm"
// myframe is no longer valid
var myframe = theFrame.document;
// myframe now references the new object

http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2brows.mspx#EFAA

Bill Thorne wrote:
> I have found a work-around which is stupid but works, wanted to post
> so others can benefit.
>
> Instead of:
>
> theFrame.src=newURL;
>
> Do:
>
> theFrame.document.open()
> theFrame.document.write('<html><body leftmargin=0 topmargin=0
> scroll="no"><iframe frameborder=no scrolling=no marginheight=0
> marginwidth=0 src="'+newURL+'" width="100%"
> height="100%"></body></html>'); theFrame.document.close();
>
> This works in terms of retaining the ability to script into the
> contained document, just have to adjust DOM reference from
> theFrame.document to theFrame.document.frames[0].document...
>
> This looks to be a BUG in IE6, as the domains of all the objects here
> are identical so there is no reason to remove the ability to script
> into a document that is inside an IFRAME that has had it's src
> property modified.
>
> This MUST be breaking a lot of sites!
>
>
>
> "Bill Thorne" wrote:
>
>> I have an SP2 problem with an iframe environment where by setting
>> the SRC property of an IFRAME I lose scripting access to the
>> document within the IFRAME. All objects, IFRAMES etc. are served
>> from the same domain, same server, same folder.
>>
>> The initial property of the SRC tag is to a dummy, empty.html
>> document and when this is active, the document.domain property can
>> be read and I verify that it has the same domain as the parent page
>> and other IFRAME objects in the page.
>>
>> As soon as the SRC property is changed to load a different document
>> in the IFRAME, all scripting access INTO the document from the
>> parent frame becomes blocked. ODDLY, scripting access from INSIDE
>> the new IFRAME to the parent is NOT, and the document's script can
>> request other IFRAMES to popup and work, etc.
>>
>> I have tried hard-coding fully qualified URL entries in the SRC to
>> try to "help" the IE security context/domain recognition but nothing
>> helps. Using the document.location.replace(newURL) method is even
>> worse, as it only works once, then since the scripting is lost, can
>> no longer load a new doc in the IFRAME (changing src attribute
>> continues to be OK, just can't access anything inside the IFRAME).
>>
>> Get a "Permission Denied" exception on trying to even read the loaded
>> document's document.domain property.
>>
>> I would appreciate any tips on how to change the document inside an
>> IFRAME without hitting this bug. I suppose I will try hosting the
>> IFRAME inside a SPAN and then reset the innerHTML of the SPAN so
>> that the SRC of the IFRAME can always be hardcoded...which I know
>> works from some other IFRAMES on the same page.
>> --
>> Bill Thorne
>> Host Integration Tools Author for .NET



Relevant Pages

  • RE: XP SP2 cross-iframe scripting
    ... document that is inside an IFRAME that has had it's src property modified. ... all scripting access INTO the document from the parent frame becomes ...
    (microsoft.public.scripting.jscript)
  • Re: File per Link in object-Tag nachladen
    ... File "telecomprojects.html" ersetzen. ... das ich statt des object etwas anderes brauche was analog zum iframe ... Scripting, und so ziemlich jeder Benutzer kann das nutzen. ... das untenstehende object-Element im Normalfall seine eigenen Scrollbars. ...
    (de.comp.lang.javascript)
  • Re: IFRAME & AJAX ; point me out
    ... Well 'to AJAX or not to AJAX' that is the question I was asking my self. ... After being defribillated :-) I thought of remote scripting using an IFRAME, after all I read a lot about how to do this and I tried to give it a shot. ... Maybe lack of cross-frame scripting support. ...
    (comp.lang.javascript)
  • Re: Iframe style
    ... IFRAME Element | iframe Object (Internet Explorer) ... Microsoft® Windows®2000 Scripting Guide ... WSH 5.6 documentation download ...
    (microsoft.public.scripting.jscript)
  • Changing the Url of an Iframe with a selection box
    ... desired url they wish to visit from the main page the iframe then loads ... passing the value of the selection wich in this case is the url to the ... independant script wich will in turn will change the src of the iframe ... the initial src then use the onchange event form the select to change ...
    (comp.lang.javascript)