Access denied in javascript when try to see contents of page in javascript opened window

A

admyc

Hello

I am trying to write some javascript that will open a new web-page in
a new window and then be able to determine if the web-page that has
been opened contains certain text.

I am opening the new window with:
newpage = window.open("http://www.somewebaddress.com/
index.html","newpage","width=400,height=200,left=400,top=300,resizable=1,status=1,scrollbars=1");

I am then trying to see if it contains certain text by using:
if(newpage.document.getElementsByTagName('body')[0].innerHTML = =
"text") alert("contains the text");

However this line seems to produce an error that says "Access denied".

Does anyone know why this is or another way of achieving my goal?

Thanks

AM
 
A

ASM

En réponse à admyc qui écrivit, en date du : 4/09/07 0:32, le message
suivant :
Hello

I am trying to write some javascript that will open a new web-page in
a new window and then be able to determine if the web-page that has
been opened contains certain text.

It is absolutly forbiden to acces to contain of another domain ... !

So your browser doesn't allow you to parse the page displayed in your
popup because probably this page comes from another domain.

Test with a file comming from your own site
to see if your script is right.

I am opening the new window with:
newpage = window.open("http://www.somewebaddress.com/
index.html","newpage","width=400,height=200,left=400,top=300,resizable=1,status=1,scrollbars=1");

I am then trying to see if it contains certain text by using:
if(newpage.document.getElementsByTagName('body')[0].innerHTML ==
"text") alert("contains the text");

However this line seems to produce an error that says "Access denied".

Acces denied to the other site's contain .... !
 
T

Thomas 'PointedEars' Lahn

admyc said:
I am trying to write some javascript that will open a new web-page in
a new window and then be able to determine if the web-page that has
been opened contains certain text.

I am opening the new window with:
newpage = window.open("http://www.somewebaddress.com/
index.html","newpage","width=400,height=200,left=400,top=300,resizable=1,status=1,scrollbars=1");

`newpage' should be declared with `var'. The window name (second argument)
should be distinguishable in order not to reuse windows from other sites.
As for the third argument, omit "left=...,", "top=...,", and all `=1'.
I am then trying to see if it contains certain text by using:
if(newpage.document.getElementsByTagName('body')[0].innerHTML = =
"text") alert("contains the text");

However this line seems to produce an error that says "Access denied".

Does anyone know why this is or another way of achieving my goal?

http://www.google.com/search?as_q="Same+Origin+Policy"&filter=0
http://groups.google.com/groups?as_...group=comp.lang.javascript&scoring=d&filter=0


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top