Manipulate page in a frame from JScript in IE6

In IE6, is it possible to manipulate a web page that's loaded in a frame from JScript in the master page? Access to the DOM and to click events would be most interesting.

If not, I guess I'll have to write an ActiveX control (and come back with more questions :-).

Hans-Georg

[296 byte] By [Hans-GeorgMichna] at [2008-2-19]
# 1

If the pages are from different domains then access is blocked for security reasons.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/xframe_scripting_security.asp

Thanks
-Dave

DaveMassy at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 2

Thanks! Now I know that it's no use to try.

Hans-Georg

Hans-GeorgMichna at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 3

As stated before, this is not possible cross-domain, however same domain it works fine. Sample code below (ie6/ff/op):

<html>

<head>

<title>Test</title>

<script type="text/javascript">

function init() {

var frame1 = document.getElementById('frame1');

if (frame1.contentDocument) {

frame1 = frame1.contentDocument.body;

} else {

frame1 = document.frames['frame1'].document.body;

}

frame1.innerHTML = 'This is my frame. Click me';

if (frame1.addEventListener) {

frame1.addEventListener('click', frameClicked, false);

} else if (frame1.attachEvent) {

frame1.attachEvent('onclick', frameClicked);

} else {

frame1.onclick = frameClicked;

}

}

function frameClicked(evt) {

evt = (evt ? evt : window.event);

alert('Frame Clicked');

}

</script>

</head>

<body onload="init();">

This is the main page

<br />

<iframe src="" id="frame1" />

</body>

</html>

maxinforum at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 4

Thanks! I may be able to redirect the frame content such that it comes from a different domain. Very interesting!

Hans-Georg

Hans-GeorgMichna at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...