473,779 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

win.document.re adystate - how to access

I would like to open a 'child' window win and check it's ready state.
Unfortunately, when I try to do so, I discover that win.document does
not appear accessable from the parent window, see below. Is this by
design or am I doing something wrong.

<HTML>
<HEAD>
<TITLE>Javascri pt Test</TITLE>
</HEAD>
<SCRIPT language="JavaS cript">
var win =
open('http://faqts.com/knowledge-base/community/index.phtml/id/601');
var iq = 0;
var q = "";
q += 'typeof window.document ' + typeof(window.d ocument) + '\n';
q += 'typeof window.document .readystate ' +
typeof(window.d ocument.readySt ate) + '\n';
q += 'typeof window.addevent Listener ' +
typeof(window.a ddEventListener ) + '\n';
q += 'typeof win.document ' + typeof(win.docu ment) + '\n';
q += 'typeof win.document.re adystate ' +
typeof(win.docu ment.readyState ) + '\n';
q += 'typeof win.addeventLis tener ' + typeof(win.addE ventListener) +
'\n';
</SCRIPT>

<H1>Check access to features</H1>
<BODY onLoad="alert(q )">

</BODY>
</HTML>
Jul 20 '05 #1
4 3979
On Sat, 14 Feb 2004 17:54:25 GMT, Richard Bell <rb********@ear thlink.net>
wrote:
I would like to open a 'child' window win and check it's ready state.
Unfortunately, when I try to do so, I discover that win.document does
not appear accessable from the parent window, see below. Is this by
design or am I doing something wrong.


It depends. If the page in the new window is from a different domain, you
might get an access error due to security restrictions. Also, you do
realise that readyState is a non-standard property and might not work on
all browsers?

At the moment, the problem is that you haven't capitalised the identifier
properly; JavaScript is case-sensitive, remember. You need to access it
with:

winObj.document .readyState (not readystate)

You have this problem with addEventListene r in a couple of places: you
write it 'addeventListen er'.

Two final comments relate to your HTML.

1) The heading, H1, and script elements are outside of valid blocks. Move
H1 within BODY and SCRIPT within HEAD or BODY, as appropriate.
2) The script element is missing the required type attribute. It should be
written as shown below. Notice that the language attribute (which is
deprecated) is not necessary when "type" is used.

<script type="text/javascript">

Hope that helps,
Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
Thanks Mike.

As it happens, the documents are definitively from another domain. As
near as I can tell this means that for an arbitrary URL, there is no
way within Javascript to determine in the new page has completed
loading as there is very restricted access to the child window's
properties and methods. Soooooooooo it seems that Javascript is not
prepared to handle my needs. Pitty, it's really rather neat.

BTW, the case was OK in the typeof where it mattered, but I've fixed
it where you noticed. Rather sloppy of me. As was the HTML.

As you can tell, I don't normally hang out here. I did a fair bit of
checking in the FAQ, newsgroup archives, etc. and found LOTS of bogus
examples/advice/... . It finially drove me to the example code I sent.
It might be worthwhile if this issue were dealt with in the FAQ as, at
least in my research, it seemed to come up fairly often.

Thanks again.

On Sat, 14 Feb 2004 18:08:45 GMT, Michael Winter
<M.******@bluey onder.co.invali d> wrote:
On Sat, 14 Feb 2004 17:54:25 GMT, Richard Bell <rb********@ear thlink.net>
wrote:
I would like to open a 'child' window win and check it's ready state.
Unfortunately, when I try to do so, I discover that win.document does
not appear accessable from the parent window, see below. Is this by
design or am I doing something wrong.


It depends. If the page in the new window is from a different domain, you
might get an access error due to security restrictions. Also, you do
realise that readyState is a non-standard property and might not work on
all browsers?

At the moment, the problem is that you haven't capitalised the identifier
properly; JavaScript is case-sensitive, remember. You need to access it
with:

winObj.document .readyState (not readystate)

You have this problem with addEventListene r in a couple of places: you
write it 'addeventListen er'.

Two final comments relate to your HTML.

1) The heading, H1, and script elements are outside of valid blocks. Move
H1 within BODY and SCRIPT within HEAD or BODY, as appropriate.
2) The script element is missing the required type attribute. It should be
written as shown below. Notice that the language attribute (which is
deprecated) is not necessary when "type" is used.

<script type="text/javascript">

Hope that helps,
Mike


Jul 20 '05 #3

Mike,

I should also have mentioned that some of the 'solutions' I found
suggested that frames made a difference. Of course, they do not.
On Sat, 14 Feb 2004 18:08:45 GMT, Michael Winter
<M.******@bluey onder.co.invali d> wrote:
On Sat, 14 Feb 2004 17:54:25 GMT, Richard Bell <rb********@ear thlink.net>
wrote:
I would like to open a 'child' window win and check it's ready state.
Unfortunately, when I try to do so, I discover that win.document does
not appear accessable from the parent window, see below. Is this by
design or am I doing something wrong.


It depends. If the page in the new window is from a different domain, you
might get an access error due to security restrictions. Also, you do
realise that readyState is a non-standard property and might not work on
all browsers?

At the moment, the problem is that you haven't capitalised the identifier
properly; JavaScript is case-sensitive, remember. You need to access it
with:

winObj.document .readyState (not readystate)

You have this problem with addEventListene r in a couple of places: you
write it 'addeventListen er'.

Two final comments relate to your HTML.

1) The heading, H1, and script elements are outside of valid blocks. Move
H1 within BODY and SCRIPT within HEAD or BODY, as appropriate.
2) The script element is missing the required type attribute. It should be
written as shown below. Notice that the language attribute (which is
deprecated) is not necessary when "type" is used.

<script type="text/javascript">

Hope that helps,
Mike


Jul 20 '05 #4
Richard Bell wrote:
Thanks Mike.

As it happens, the documents are definitively from another domain. As
near as I can tell this means that for an arbitrary URL, there is no
way within Javascript to determine in the new page has completed
loading as there is very restricted access to the child window's
properties and methods. Soooooooooo it seems that Javascript is not
prepared to handle my needs. Pitty, it's really rather neat.


One possible solution, that could get kind of nasty, is to use an
HTTPRequestObje ct to retrieve the .html file, parse it and possibly add
a <base href> tag to make relative links/URLs work properly, and then
write it to a new open window, then you could have access to its
properties/methods.

Only place I know its supported is Moz and IE though.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #5

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

Similar topics

2
2715
by: Adam | last post by:
This is frustrating me. Opening IE displays the following code fine. When I open a new window the code no longer works. All the HTML is overwritten with the first document.write statement. Tried with window tried without Please help. This code pulls XML from a web site then parses it into a dynamically created table built with javascript. The write table is not working correctly, other methods work fine. This code also locks up Fire Fox...
3
3473
by: Thomas Seidel | last post by:
Hi NG, I would like to write a specific library that gets it data from a specific webpage. Because not all web sites are XHTML I guess I have to use the old com library MSHTML. Beacause it should be all done in the library without forms I cant use the AxWebBrowser ocx. Thats why I tried the following: ((IHTMLDocument2)hd).write("<html></html>");
9
6874
by: John Williams | last post by:
How do I load a HTML page (via URL) and parse the DOM in a Console Application? I've successfully done all this in a Windows Application by using the WebBrowser control, calling the Navigate method on the specified URL, and then, within the DocumentComplete event, parsing the HTML page using mshtml.HTMLDocument. I'm writing it as a console app because I don't need to display the HTML, just search for a specific tag and retrieve a href...
7
5909
by: Desmond Cassidy | last post by:
Hi, I have being trying to get a grip of HTML data manipulation and am using the mshtml class and System.Net to retriver HTML pages. Now as far as I can see, one can read HTML in different ways. 1. Using the WebBrowser and loading the HTML into the mshtml.HTMLDocument class and then step through the various tags (input, a), tables etc. 2. Use System.Net.WebRequest/Response to load the data into a HTML string using a Stream Reader. Now...
7
9766
by: Asterbing | last post by:
Hi, Talking about a js script which changes an iframe src through a "ref_to iframe.setAttribute("src", document_path);", I would like to launch a check() fct when this new document is loaded. Of course, knowing, I don't want (and can't n some cases where document is generated by a cgi script) to edit every possible document which is potentially loadable in the iframe.
2
3642
by: coolvirus | last post by:
I'm using the XMLHTTPRequest JavaScript object to fetch updated info from the server. The problem I'm having occurs on Windows 2000/IE 6. There is a very long pause on readyState 3 (close to a minute, maybe more) but it eventually gets to readyState 4. I have no idea why. The page works just fine on Windows XP/IE 6. There is no delay or hang up on the server side as far as I can tell (if we get to readyState 3 is because the server...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5373
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
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 we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.