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

Discussion in 'Javascript' started by admyc, Sep 3, 2007.

  1. admyc

    admyc Guest

    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
     
    admyc, Sep 3, 2007
    #1
    1. Advertising

  2. admyc

    ASM Guest

    Re: Access denied in javascript when try to see contents of pagein javascript opened window

    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 .... !

    --
    ASM
     
    ASM, Sep 4, 2007
    #2
    1. Advertising

  3. Re: Access denied in javascript when try to see contents of pagein javascript opened window

    admyc wrote:
    > 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
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, Sep 4, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. raj
    Replies:
    8
    Views:
    623
    J. Baute
    Apr 9, 2004
  2. Manjit
    Replies:
    0
    Views:
    238
    Manjit
    Jul 25, 2003
  3. datactrl
    Replies:
    3
    Views:
    161
    Thomas 'PointedEars' Lahn
    May 29, 2004
  4. Mark
    Replies:
    2
    Views:
    140
  5. Diego Fernández Santos
    Replies:
    2
    Views:
    254
Loading...

Share This Page