468,733 Members | 1,431 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,733 developers. It's quick & easy.

Accessing window.parent from HTML contained in dynamically created IFRAME

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);
}
Jul 23 '05 #1
1 2465
me******@bezeqint.net (BGMeshi) wrote in message news:<df**************************@posting.google. com>...
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!
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by veganeater | last post: by
4 posts views Thread by Paul Brant | last post: by
1 post views Thread by onali1811 | last post: by
14 posts views Thread by Aaron Gray | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.