Solved

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

Posted on 2012-03-10
4
256 Views
Last Modified: 2012-03-17
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
Comment
Question by:dwoolley3
  • 2
  • 2
4 Comments
 
LVL 21

Expert Comment

by:Kim Walker
ID: 37706934
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
 

Author Comment

by:dwoolley3
ID: 37707635
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
 
LVL 21

Accepted Solution

by:
Kim Walker earned 500 total points
ID: 37707981
That is correct. You would not be able to access the contents of the external page from a page in your own domain.
0
 

Author Closing Comment

by:dwoolley3
ID: 37733829
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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now