473,466 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Accessing contents inside an iframe

2 New Member
What I'm trying to accomplish:
I have an html on my harddrive that includes another local file (plain text) through an iframe. I'd like to also parse that plain text file using javascript, and put a summary a little further down on the page.

Here's my current code:
Expand|Select|Wrap|Line Numbers
  1.          var myFrame = document.getElementById("theframe");
  2.          var myDoc = myFrame.document;
  3.          var myContent = myDoc.firstChild;
  4.  
The error console in firefox says: "myDoc has no properties (line 3)".

I only care if this works on firefox, since I'm planning to just use it myself. There shouldn't be any access violation, since both documents come from the same location. Is there anything I can do to get this to work?
Jul 31 '07 #1
7 2724
gits
5,390 Recognized Expert Moderator Expert
hi ...

you may use something like this:

Expand|Select|Wrap|Line Numbers
  1. function get_iframe_content(frame_name) {
  2.     // refer the frame by name and the frame's document
  3.     var doc = window.frames[frame_name].document;
  4.     alert(doc.firstChild.innerHTML);
  5. }
  6.  
kind regards
Aug 1 '07 #2
uigrad
2 New Member
hi ...

you may use something like this:

....
Thank you so much for responding! It worked great, this topic can be closed.

I had tried something like that, but I had used "top.frames[ ]" instead of "window.frames[ ]", based on something from a different site.
Aug 1 '07 #3
gits
5,390 Recognized Expert Moderator Expert
hi ...

glad to hear that you got it working ... post back to the forum whenever you have a question ;)

kind regards
Aug 2 '07 #4
Amuthaangler
4 New Member
Hi all,

I am facing a similar problem.I am uploading an image and I get the response from the server in an IFrame in JSON format. Is there any way to parse the response and get the image id which is the response from the server.

Any help would be greatly appreciated

With thanks,
Amutha
Aug 2 '07 #5
gits
5,390 Recognized Expert Moderator Expert
Hi all,

I am facing a similar problem.I am uploading an image and I get the response from the server in an IFrame in JSON format. Is there any way to parse the response and get the image id which is the response from the server.

Any help would be greatly appreciated

With thanks,
Amutha
in case you have json then simply eval the responseText and you get a native js-array/object that is easy to handle ... like every array/object ... where is your problem in particular?

kind regards
Aug 2 '07 #6
Amuthaangler
4 New Member
Hi gitz,

Thanks for your immediate response.

Let me explain you my current requirement. I am using IFrame for Uploading PIcture. My form's target points to IFrame. Now when I upload the picture, myserver side ROR script handles the same and posts the JSON response in the IFrame.The JSON response contains the uploaded Image Id, type and the Image name. I am able to view this when I make the IFrame as visible.

Any suggestions to access the Image Id from the response?

With thanks,
Amutha
Aug 2 '07 #7
gits
5,390 Recognized Expert Moderator Expert
you mean ... the json-response is written to the iframe's source-document? so you may retrieve that text like it is showed in the above example ... assign it to a js-variable:

Expand|Select|Wrap|Line Numbers
  1. var response = // json-string ;)
  2.  
  3. var upload_response = eval(response);
  4.  
  5. // now you may get the values of obj-properties
  6. // may be the json-data was: {a: 'value1', b: 'value2', id: 'value3'}
  7. var img_id = upload_response.id;
kind regards
Aug 2 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Julius Mong | last post by:
Dear all, I have something like this: <html... > <embed ...> </html> Am I out of luck if I wanted to access the embedded DOM and manipulate its content? Or if I have:
0
by: Bruce E. Pullum | last post by:
Ok, I really need some help here.... I have an ASPX page, that contains a save button. It also has an IFRAME that has a tabstrip and multipage control. What I am trying to do is to allow the...
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: jaktharkhan | last post by:
Hi, I really really need help in trying to figure out how can I do a CloneNode on an Iframe where the cloned IFRAME clones with all its contents?. Basically what I am doing is dynamically building...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.