IFrame access test 
Author Message
 IFrame access test

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.*-*-*.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



Tue, 06 Dec 2005 14:23:16 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST

2. IFrame access travails

3. TEST TEST TEST TEST

4. alt.test,comp.test,misc.test,news.test

5. TEST: microsoft.public.access.modulesdaovba propagation TEST message

6. How to access iFrame via DOm structure in fllowing DHTML code

7. Access text inside IFRAME

8. Scripting MSIE IFRAME for local file access

9. IFrame access travails

10. IFRAME DHTML access

11. Accessing Javascript variables inside an IFRAME

12. Access to Parent DOM from within an iFrame

 

 
Powered by phpBB® Forum Software