473,624 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transfer javascript code from iFrame to a DIV

Hi,

I have HTML form whose target is an invisible IFrame. After the IFrame
is loaded completely,
following code transfers contents of IFrame to DIV

document.getEle mentById("mainD iv").innerHTM L =
test_iframe.doc ument.body.inne rHTML;

but this does not seem to carry over the Javascript code from IFrame to
DIV.
Can anyone comment if this is the correct behavior or a bug?
(The requirement is to submit a form and update only portion of screen,
without using
AJAX. A DIV cannot be target of the FORM, hence the IFrame->DIV route)

Thanks,
Sameer

Apr 28 '06 #1
4 5930
sa******@gmail. com wrote:
I have HTML form whose target is an invisible IFrame. After the IFrame
is loaded completely, following code transfers contents of IFrame to DIV

document.getEle mentById("mainD iv").innerHTM L =
test_iframe.doc ument.body.inne rHTML;
<URL:http://pointedears.de/scripts/test/whatami#inferen ce>
but this does not seem to carry over the Javascript code from IFrame to
DIV. Can anyone comment if this is the correct behavior or a bug?
`innerHTML' is a proprietary feature, so everything regarding it can be
considered correct behavior, even bugs.
(The requirement is to submit a form and update only portion of screen,
without using AJAX. A DIV cannot be target of the FORM, hence the
IFrame->DIV route)


This is utter nonsense. Simply make the IFrame visible in the first
place, and use CSS to style it.
PointedEars
--
A man who works with his hands is a laborer; a man who works with his
hands and his brain is a craftsman; but a man who works with his hands
and his brain and his heart is an artist.
-- Louis Nizer, lawyer (1902-1994)
Apr 29 '06 #2

sa******@gmail. com wrote:
Hi,

I have HTML form whose target is an invisible IFrame. After the IFrame
is loaded completely,
following code transfers contents of IFrame to DIV

document.getEle mentById("mainD iv").innerHTM L =
test_iframe.doc ument.body.inne rHTML;

but this does not seem to carry over the Javascript code from IFrame to
DIV.
Can anyone comment if this is the correct behavior or a bug?
(The requirement is to submit a form and update only portion of screen,
without using
AJAX. A DIV cannot be target of the FORM, hence the IFrame->DIV route)

Thanks,
Sameer


Is the javascript inside the body of the IFRAME? To copy the contents
completely as they are, I would use
var content = test_iframe.doc ument.body.clon eNode( true );
document.getEle mentById("mainD iv").appendChil d( content );

Apr 29 '06 #3
bobzimuta wrote:
[...]

Is the javascript inside the body of the IFRAME? To copy the contents
completely as they are, I would use
var content = test_iframe.doc ument.body.clon eNode( true );
document.getEle mentById("mainD iv").appendChil d( content );


But 'content' will be a body element, putting a body element inside a
div may have serious implications. You should probably loop through the
child nodes of 'content' and add them to the div one by one:
var content = test_iframe.doc ument.body.clon eNode( true );
var div = document.getEle mentById("mainD iv");

while (content.firstC hild) {
div.appendChild (content.firstC hild);
}
--
Rob
Apr 29 '06 #4
Thanks all of you for your replies.
Our architect suggested a simple solution. We added following code in
the JSP that loads in the IFrame

<script language="javas cript">
AddUserControll er = function() {
this.validate = function(formOb j) {
// validation code
}
}
window.parent.d ocument.addUser Controller = new AddUserControll er()
;
</script>

This add a Javascript object called addUserControll er in the parent
document and then
The code loaded in IFrame can use addUserControll er to call functions
like validate().

<script language="javas cript">
window.parent.g etIFrameData();
</script>

getIFrameData() is defined in parent document.
function getIFrameData()
{
document.getEle mentById("mainD iv").innerHTM L =
test_iframe.doc ument.body.inne rHTML;
} // getIFrameData() .

We initially were using DWR, but it allows accessing only POJOs
through AJAX and
we wanted to call just the JSP. We found that DWR uses same IFrame
mechanism
if posting method is IFrame instead of XMLHttpRequest (but still posts
to POJO).
Is there any recommended,wel l tested AJAX library that can be used
here to post to
any URLs?

Thanks,
Sameer

Apr 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2146
by: Keith Patrick | last post by:
I have an app where a Shockwave splash animation starts off my app and then sets its parent iframe's src to the value of a default page "BasicReports". BasicReports has a link to another report page, but when I click it and redirect via Server.Transfer (using both values for preserveForm), the first time, it loads up BasicReports again. If I click BasicReports *again*, then it transfers to the correct page. Is there a known behavior/bug...
8
1821
by: p3t3r | last post by:
I am using .NET2 and have a number of aspx pages. On each page is a LinkButton that performs a server.transfer() to another page. If we use page names A,B,C,D,E as an example. I start on page A and do a server.transfer to page B. The address bar still shows page A (which is what I want). Page B then does a server.transfer to page C. Now the address bar shows the URL for page B (not C and not A which is what I want). Every new...
5
2193
by: Tudor Tihan | last post by:
Hi, This is my first post here, so please be kind. I have tryed to make a javascript html page loader by using an invisible <IFrame> and some javascript variable text passing between entities. This seems to brake the CSS after some depth, or perhaps I am not understanding something.
8
3653
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
18
43535
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. (It's for Google Maps, but I won't bore you with the complexities of that, as it doesn't affect the question). Mochas kudos to anyone able to solve this widdle.
15
2247
by: Phlip | last post by:
Javascripters: I have an outer page and an inner iframe. The outer page calculates some javascript, and wants the inner frame to run it. The inner frame should hit a page on the same (private) web server, so this is not a cross-site scripting attack. But I would prefer not to taint the target page with any extra logic to do this. (I will if I must.) The calling page has these elements:
5
7699
by: brad | last post by:
I'll post my code below. My goal is to grab the selected text in an iFrame from javascript (really any way possible). When I highlight text in the iFrame and click the link outside of the iFrame, I receive the following error: Firefox FireBug Error uncaught exception: Permission denied to get property HTMLDocument.getSelection IE7 Error
9
16881
by: gwong123 | last post by:
Hey, I need to convert this javascript code into iframe. The javascript goes into a server and brings out an ad banner. The X's is the server IP. <script language="javascript" type="text/javascript" src="http://XXX.XXX.XXX.XXX/blahblah/0000/blahblahblah.php"></script> What I need to do is convert that line of code into an iframe format so that it does the same job of going into the server and pulling out the banner. Right now if I just...
0
1500
by: johnw182 | last post by:
Ok, I have a asp.net project. Everything works great. HOWEVER, this project was made to be called from within a frame or iframe. When being used within the iframe the user gets a blank frame when clicking certian buttons. Here is the code for the iframe. <iframe src="http://www.website.com/?cid=A195E1A9-A5D7-4046-89A4-1C00D4F81E35" id="frameName" frameborder="0" width="550" height="750"></iFrame> Here are the steps taken to reproduce.
0
8231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8614
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.