473,394 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 2616
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lee | last post by:
I am using a modal window and an iFrame to try and pull a return value back. I am doing this across domains. I have the value returned from the modal window to the iFrame window but I can not...
2
by: veganeater | last post by:
Hello again everyone, I seem to have run into another problem... perhaps I'm just a bit slow. The problem is something like this: I have a popup window launched by a page sourced in an iFrame ...
4
by: Paul Brant | last post by:
Hi all, I have a page with an IFRAME in it. From a script in the main ( parent ) page I instruct the IFRAME to load a specific URL. The URL contains parameters that are processed by the server....
1
by: onali1811 | last post by:
Hi, I have a page which has a div tag like following: <div name="searching" id="searching" style="width:100px;display:block;float:left">Searching...</div> Now i have an iframe, which also...
14
by: Aaron Gray | last post by:
Hi, I want to access the properties of an IFrame but seem unable to get access to the IFrames document body. <html> <body> <iframe src="test.html" id="IFrame"></iframe> </body>
1
by: adamredwards | last post by:
I have a page with some form elements that are dynamically generated. They are inserted into the dom by first cloning a node, changing the values like name, and then inserted with insertBefore(). ...
2
by: Vivek | last post by:
I have two html files Parent.htm and Child .htm Following is the code inside the Parent.htm: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title></title>...
2
by: KC | last post by:
Hi, Every JavaScript executive context has a top-level window and we can use window.open() to open another window ... Does this related to Windows created by click on "File"->"New Window" or...
4
by: Jayyde | last post by:
Is there any way to capture a button click inside an iFrame and perform both an action on that page and one on the parent page? Basically I have a page atm that allows the user to add a record to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.