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