Topic: "a javascript issue..." (page 1 of 1)

1
Author Post
aceldama
groupmastergroupmastergroupmastergroupmaster
i've been trying to figure it out (on both mozilla and ie7) till my head feels like exploding. (formatted for readability)

can someone please tell me why this works:
<script>
    function gData(){alert(parent.window.frames.length);}
</script>
<iframe src="http://xxxx.com" name="myIframe" onload="gData()"></iframe>

[output: 1] - which means that there definitely is a frame in the frames array (ie. frame[0])

<script>
    function gData(){alert(parent.window.frames[0].window.document);}
</script>
<iframe src="http://xxxx.com" name="myIframe" onload="gData()"></iframe>

[output: object htmlDocument] - which tells me that the frame's document object is accessible :(

but this however, doesn't work:
<script>
    function gData(){alert(parent.window.frames[0].window.document.cookie);}
</script>
<iframe src="http://xxxx.com" name="myIframe" onload="gData()"></iframe>

[no output]
Edited by aceldama on 27.11.2007 13:41:16
private message
aceldama
groupmastergroupmastergroupmastergroupmaster
sorry for the bump, but please can anyone help me here?
private message
Bander
groupmastergroupmaster
I'll just make a wild guess and say try adding a semi colen. I didn't test this at all though.

QuoteQuote:
onload="gData();"
private message EMail
unknown user
I don't want to come off all arrogant now, but that will not _work_

Browsers don't allow this for obvious security reasons, perhaps if you turn down the security settings. But otherwise this will not work. Browser restrictions. Otherwise anybody with a website, like google could collect every bodies cookies. Which would make hunting for XSS bugs obsolete ...
EMail
Bander
groupmastergroupmaster
Oh duh. Yeah, you can't execute your own JS inside other peoples pages.

/me wasn't looking closely
Edited by Bander on 28.11.2007 04:04:45
private message EMail
unknown user
just open the javascript console in firefox, or surf to
chrome://global/content/console.xul in another window

and you will see the message

"Uncaught exception permission denied to get property ..."

or put it in a try catch block ...
EMail
aceldama
groupmastergroupmastergroupmastergroupmaster
ah, i see :) thank you rhican. once again you were of much help. -forever learning-
private message
aceldama
groupmastergroupmastergroupmastergroupmaster
can anyone tell me if it's possible to set the iframe location to the javascript inline debugger? i'm using this code, but it results in a really odd error: "uncaught exception: ReferenceError: alert is not defined"
<html>
    <head>
        <script>
            function xReload(){document.getElementById("IF01").src="javascript:alert('reloaded-frame');";}
        </script>
    </head>
    <body>
        <iframe id="IF01" src="http://google.com/" onload="xReload();"></iframe>
    </body>
</html>

EDIT: i mean, i've googled, but can't seem to find whether it's the same issue i was dealing with all that time ago.
Edited by aceldama on 18.03.2010 20:51:36
private message

Topic: "a javascript issue..." (page 1 of 1)

1