Accessing window.parent from HTML contained in dynamically created IFRAME

B

BGMeshi

Hi,

The following javascript code (serving a main HTML page) dynamically
creates
IFRAME to contain other HTML page. Everyting works OK, however when I
am trying
to access the main HTML page elements from the child page by
window.parent.document... a javascript error is accepted.
Any Idea?
TIA Boris

function OpenLayer (HtmlName, atop, aleft, awidth, aheight, acolor)
{
DIVText = '<DIV ID = "LayerDiv"></DIV>';
var newDiv = document.createElement(DIVText);
FormID.insertBefore(newDiv);
document.all.LayerDiv.style.position = "absolute";
document.all.LayerDiv.style.top = atop;
document.all.LayerDiv.style.left = aleft;
document.all.LayerDiv.style.background = acolor;
document.all.LayerDiv.style.visibility = "visible";
OpenHTML (HtmlName, atop, aleft, awidth, aheight, acolor);
}

function OpenHTML (HtmlName, atop, aleft, awidth, aheight, acolor)
{
HTMLText = '<IFRAME '
HTMLText += 'SRC=' + HtmlName + ' ';
HTMLText += 'ID="IFrameLayer" ';
HTMLText += 'NAME="f1" ';
HTMLText += 'WIDTH="' + awidth + '" ';
HTMLText += 'HEIGHT="' + aheight + '" ';
HTMLText += 'BGCOLOR="' + acolor +'" ';
HTMLText += 'scrolling="NO" frameborder="NO"';
HTMLText += '><\/IFRAME>';
LayerDiv.insertAdjacentHTML('BeforeEnd', HTMLText);
}
 
B

BGMeshi

Hi,

The following javascript code (serving a main HTML page) dynamically
creates
IFRAME to contain other HTML page. Everyting works OK, however when I
am trying
to access the main HTML page elements from the child page by
window.parent.document... a javascript error is accepted.
Any Idea?
TIA Boris

function OpenLayer (HtmlName, atop, aleft, awidth, aheight, acolor)
{
DIVText = '<DIV ID = "LayerDiv"></DIV>';
var newDiv = document.createElement(DIVText);
FormID.insertBefore(newDiv);
document.all.LayerDiv.style.position = "absolute";
document.all.LayerDiv.style.top = atop;
document.all.LayerDiv.style.left = aleft;
document.all.LayerDiv.style.background = acolor;
document.all.LayerDiv.style.visibility = "visible";
OpenHTML (HtmlName, atop, aleft, awidth, aheight, acolor);
}

function OpenHTML (HtmlName, atop, aleft, awidth, aheight, acolor)
{
HTMLText = '<IFRAME '
HTMLText += 'SRC=' + HtmlName + ' ';
HTMLText += 'ID="IFrameLayer" ';
HTMLText += 'NAME="f1" ';
HTMLText += 'WIDTH="' + awidth + '" ';
HTMLText += 'HEIGHT="' + aheight + '" ';
HTMLText += 'BGCOLOR="' + acolor +'" ';
HTMLText += 'scrolling="NO" frameborder="NO"';
HTMLText += '><\/IFRAME>';
LayerDiv.insertAdjacentHTML('BeforeEnd', HTMLText);
}


Something else I noticed while testing this code: this.name in the
script serving the child HTML page gives a name of IFRAME (f1) (I.e
element on the parent HTML) instead the name of appropriate element on
the child HTML!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top