Solved

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

Posted on 2012-03-10
4
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 22

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 22

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET Calendar Control 5 26
DataTable column sorting incorrectly 2 22
null, truthy, falsey confusion 25 33
Validation for a field in asp.net 3 14
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

733 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