Connecting Tech Pros Worldwide Help | Site Map

win.document.readystate - how to access

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 02:31 PM
Richard Bell
Guest
 
Posts: n/a
Default win.document.readystate - 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>Javascript Test</TITLE>
</HEAD>
<SCRIPT language="JavaScript">
var win =
open('http://faqts.com/knowledge-base/community/index.phtml/id/601');
var iq = 0;
var q = "";
q += 'typeof window.document ' + typeof(window.document) + '\n';
q += 'typeof window.document.readystate ' +
typeof(window.document.readyState) + '\n';
q += 'typeof window.addeventListener ' +
typeof(window.addEventListener) + '\n';
q += 'typeof win.document ' + typeof(win.document) + '\n';
q += 'typeof win.document.readystate ' +
typeof(win.document.readyState) + '\n';
q += 'typeof win.addeventListener ' + typeof(win.addEventListener) +
'\n';
</SCRIPT>

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

</BODY>
</HTML>

  #2  
Old July 20th, 2005, 02:31 PM
Michael Winter
Guest
 
Posts: n/a
Default Re: win.document.readystate - how to access

On Sat, 14 Feb 2004 17:54:25 GMT, Richard Bell <rbell01824@earthlink.net>
wrote:
[color=blue]
> 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.[/color]

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 addEventListener in a couple of places: you
write it 'addeventListener'.

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.Winter@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
  #3  
Old July 20th, 2005, 02:31 PM
Richard Bell
Guest
 
Posts: n/a
Default Re: win.document.readystate - how to access

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.Winter@blueyonder.co.invalid> wrote:
[color=blue]
>On Sat, 14 Feb 2004 17:54:25 GMT, Richard Bell <rbell01824@earthlink.net>
>wrote:
>[color=green]
>> 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.[/color]
>
>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 addEventListener in a couple of places: you
>write it 'addeventListener'.
>
>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[/color]

  #4  
Old July 20th, 2005, 02:31 PM
Richard Bell
Guest
 
Posts: n/a
Default Re: win.document.readystate - how to access


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.Winter@blueyonder.co.invalid> wrote:
[color=blue]
>On Sat, 14 Feb 2004 17:54:25 GMT, Richard Bell <rbell01824@earthlink.net>
>wrote:
>[color=green]
>> 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.[/color]
>
>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 addEventListener in a couple of places: you
>write it 'addeventListener'.
>
>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[/color]

  #5  
Old July 20th, 2005, 02:31 PM
Randy Webb
Guest
 
Posts: n/a
Default Re: win.document.readystate - how to access

Richard Bell wrote:
[color=blue]
> 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.[/color]

One possible solution, that could get kind of nasty, is to use an
HTTPRequestObject 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.javascript FAQ - http://jibbering.com/faq/

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.