• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • Last Modified:

How can I access displayed data on one window from another window?

I have a Web application that inserts a record into a database table. After inserting the record successfully, I open a new window that is dynamically built JavaScript in the ASP.NET Code Behind (in C#). In that window, I have an HTML page using Frames that displays 4 pages: header, instructions, results from submitting a form to an external web page, and a footer. In the 3rd page in the Frame set, I am submitting a form containing XML via JavaScript to an external web page that returns some XML with a needed Ticket Number. Thus, the user will always see this Ticket Number in the context of the header & instructions and the footer.

With that as background, is there a way to be able to read and capture the data that is displayed in the 3rd framed window from another window so that I can write this Ticket Number into the database table's record? In general, if I have any kind of window that executes an external web page that provides info such as a ticket number, can I capture that information from some other window so that I can use it and update my record with it?
0
dwoolley3
Asked:
dwoolley3
  • 2
  • 2
1 Solution
 
Kim WalkerWeb Programmer/TechnicianCommented:
Theoretically, if all the pages are from the same domain, you can traverse the DOM from one iFrame to another. Javascript in iFrame1 can access the parent which can access the document in iFrame2. If iFrame2 contains a form named "someform" you could access it like.
var iframe2 = parent.document.getElementById('iframe2');
var someFormIniFrame2 = iframe2.document.someform;

Open in new window

Again, this is theoretical. I have often accessed the parent from within the iFrame and the iFrame from the parent, but never from iFrame to iFrame. Also, I must reiterate that they must be in the same domain. Browser security appropriately prevents pages in one domain from accessing pages from another domain.
0
 
dwoolley3Author Commented:
That is a good response. So, if one of those frames starts out as an html page within the domain and then redirects to an external page (e.g. www.cnn.com), can other frame pages access the data from this other page? Sounds like the browser will not allow it for security reasons.
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
That is correct. You would not be able to access the contents of the external page from a page in your own domain.
0
 
dwoolley3Author Commented:
Thank you for your answer and for your discussion on Frames.
As a result, I abandoned my initial design, and I have successfully rewritten things so that I am able to use the Web Service and Web Methods of the external Web application to perform a process and to obtain its results for posting in my ASP.NET web site.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now