IFrame access test

From: Csaba2000 (news_at_CsabaGabor.com)
Date: 06/20/03


Date: Fri, 20 Jun 2003 02:23:16 -0400


I hope I may ask the indulgence of the group to make a test for me
since I only have access to IE 5.5 on Win 2K Pro. I would very much
appreciate it if someone could run the following .VBS file on a different
system and report the results. I'm particularly interested in
Win 2K / XP configurations with IE 6

The VBScript code below will open a new IE window, load google
into an IFrame, and attempt to set the query element. It doesn't
submit anything. If the test passes, you'll see a message saying so
in the query element. If it doesn't pass, I expect you'll get an error
message about an element being inaccessible.

The test below passes on my system, but it will probably fail on yours.
(We could debate the merits of the appropriateness of this behaviour,
but first I'd like to establish what the behaviour actually is). I suspect
it is an indication of a security flaw on my system, and that is what I
am trying to track down.

Thanks,
Csaba Gabor from New York

'The following tests an IFrame access issue.
'It passes if a message appears in the google input text element

'First section loads up Google in an iframe
page = "Javascript:'<html><head><title>IFrame Woes</title></head>"
page = page & "<body>Hi Mom<br><center>"
page = page & "<IFrame frameborder=0 src=""http://www.google.com""></IFrame>"
page = page & "</center><br>Hi Dad</body></head>'"
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate page
ctr=30 'allow 6 second load time
Do While IE.busy
    WScript.Sleep 200 'Use Sleep in VB
    ctr = ctr-1
    if ctr=0 then MsgBox "Page didn't load in Time": WScript.Quit
Loop
Set frameElem = IE.document.getElementsByTagName("IFRAME")(0)

'Next line is the real test - is iDoc set properly?
Set iDoc = frameDoc(frameElem) 'Causes screen flicker

'----------- The part between the dashed lines is not essential ... ------------
'We may as well make it pretty, even if it's just a test
If Not backComp(frameElem) Then 'IE 6 code untested, from Martin Honnen
    frameElem.style.height = (iDoc.documentElement.scrollHeight + 5) & "px"
    frameElem.style.width = (iDoc.documentElement.scrollWidth + 5) & "px"
Else 'IE 5.5 code
    frameElem.style.height = (iDoc.body.scrollHeight + 5) & "px"
    frameElem.style.width = (iDoc.body.scrollWidth + 5) & "px"
End If

Function backComp(frameElem)
    'determine .document.compatMode setting - VB/Script complains
    page = """frDoc=self.dialogArguments.Document;"
    page = page & "self.returnValue=(!frDoc.compatMode)||"
    page = page & "(frDoc.compatMode==\'BackCompat\');self.close()"""
    page = "Javascript:'<html><head></head><body onLoad=" & page & "></body></html>'"

    backComp = frameElem.document.parentWindow.showModalDialog(page, frameElem)
End Function
'----------- ... to the test. It may be commented out -------------------------

iDoc.getElementsByName("q")(0).value = "Close this window. There is no bug."

Function frameDoc(frameElem)
    'Get contained body of a frame element - VB/Script can't do this - must be JavaScript!
    page = """self.returnValue=self.dialogArguments.Document;self.close()""" 'Don't touch!
    page = "Javascript:'<html><head></head><body onLoad=" & page & "></body></html>'"

    Set frameDoc = frameElem.document.parentWindow.showModalDialog(page, frameElem)
End Function



Relevant Pages

  • How to highlight some text in an iframe by script?
    ... I have an iframe in my page. ... Actually what I want is just like the google ... I will load the a page from another URL into iframe ... By JS or VBScript? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: msconfig and trojans.
    ... and is also not in the registry after I have deleted it, that presumably, it does not load on start-up. ... Google seem to be intent on destroying their $78 billion dollar market capitalisation by blocking innocent users or customers from their search engine. ... Have you noticed this stupid Google captcha page recently? ... If we re-configure a web browser not to use the proxy server, then our PC's IP Address does not trigger this stupid captcha block. ...
    (alt.comp.anti-virus)
  • Re: Id RTFM if they actually GAVE me a FM!!
    ... > is that Google usually gives an answer quicker than the so-called ... Load the A thing with one. ... Load the A thing from the location referenced as BUM. ... Load the B thing with the loacation referenced as FINGER. ...
    (alt.comp.lang.borland-delphi)
  • Re: Internet Explorer loading issue
    ... I have a brand new machine with Windows Vista Business running on it. ... takes around 8-10 seconds to load the homepage, i.e google. ... do you have the Google toolbar selected on that PC? ...
    (microsoft.public.windows.vista.general)
  • Re: API
    ... but they do their best at reducing the load on their ... server and the extent of SERP subversion. ... the overhead of the request is probably the ... They are used for Google ...
    (alt.internet.search-engines)