473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Reading content of a HTML that I've open in a subwindow...

Hi all,

Well I don't know if it's possible, but I would like to able to read
the content of a html file that I've opened in a new window, but do
this from the parent html file.
I think that maybe this isn't at all possible. But if anybody as an
idea it would be great.

The code is bellow
thx
Hugo
Parent page:
------------
<html>
<head>
<title>Test</title>
<script language="JavaScript1.2" type="text/javascript">
<!--
var myWindow;
function detect(){
myWindow = window.open("http://localhost/webapp1/status.html",
"Status");
alert(myWindow.document.forms[0].hidden_status);
myWindow.document.close() ;
}
//-->
</script>
</head>
<body>
<form>
<input type="button" VALUE=" Test Server" ONCLICK="detect();">
</form>
</body>
</html>

Child file:
----------
<html>
<head>
<title>Server</title>
</head>
<body>
<form name="my_form">
<input type="hidden" name="hidden_status" value="on"/>
</form>
</body>
</html>
Jul 20 '05 #1
2 1920
Hu*********@web.de (Hugo) writes:
Hi all,

Well I don't know if it's possible, but I would like to able to read
the content of a html file that I've opened in a new window, but do
this from the parent html file.
I think that maybe this isn't at all possible. But if anybody as an
idea it would be great.
It is not possible if the page is from another domain. The standard
security measures prevents scripts from gaining cross-domain
information.

If the page is from the same domain, you can access it as you do the
current page, only writing "myWindow.document" instead of just
"document".
function detect(){
myWindow = window.open("http://localhost/webapp1/status.html",
"Status");
alert(myWindow.document.forms[0].hidden_status);
Here you might be a little too fast. The contents of the window
is loaded asynchroneously, so it is probably not loaded yet when
the alert statment is executed.

You can either delay the alert
setTimeout(function(){
alert(myWindow.document.forms[0].hidden_status);},
1000);
(or however long you expect it to take ... the safest bet would be to check
if the page has loaded and reschedule the alert for later if it hasn't).
myWindow.document.close() ;


You probably mean
myWindow.close()
to close the window.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
DU
Hugo wrote:
Hi all,


DO NOT MULTI-POST in several newsgroups.

You posted the same question in netscape.devs-javascript

DU
---------------------------
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #3

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

Similar topics

27
by: Gene Ellis | last post by:
Something strange is happening, but I bet it is a quick fix. My favicon image is showing up in the URL bar, for a couple of seconds, but then it disappears and the default browser icon is...
1
by: Cognizance | last post by:
Hi gang, I'm an ASP developer by trade, but I've had to create client side scripts with JavaScript many times in the past. Simple things, like validating form elements and such. Now I've been...
1
by: Marcel | last post by:
I have a subwindow hich displays a grid. When the user selects a row from the grid, I wish to store the selected row ID in session state and close the subwindow, returning focus to the parent...
1
by: Richard Browne | last post by:
I have been developing a program that takes a database of email bodies and then displays them to the user in a similar way to Outlook Express would. The problem I'm having is showing only the...
3
by: nbohana | last post by:
I would like leave some windows open while go to others. Is there a way to do this. There must be some Parameter or code that I need to use. Please help!! -- Norm Bohana
1
by: DaveG | last post by:
Hi All I am having a small problem with window.open() obviously something I am or am not doing. This is being fired from a subwindow. Everytime I use just the location.href = "URL" I got a...
6
by: Wolf Grossi | last post by:
Greetings, how to refresh a parent window after processing forms from the subwindow? Currently I have a solution (see below) which works with IE and Konqueror, but not with Firefox, so I...
4
by: robin1983 | last post by:
Hi guys, i have a php file to read to content, the following is the code <?php include "config.inc.php"; include "connect.inc.php"; if(isset($_GET)) { $id =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...

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.