Hard to find problem for specialists !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fabrice Labrousse

    #1

    Hard to find problem for specialists !

    Hello,

    Here is a hard problem i cannot solve about window.opener method
    I think you'll need to be a specialist to find the solution... i can't find
    the solution by myself ! Please help me.
    Here is the problem (quiet complicated to explain).

    I use two differents servers with two IIS 4.0 Web servers

    On the first one (let's name it Server1) i got my web site. On my web site,
    i have a page (A.html) that calls (in javascript) a new window that loads a
    PHP script that remains on the second server. Are you following me ?

    On the second server (let's name it Server2) there is the so-called PHP
    script "lookfor.ph p" that browse the system file of my server (of course i
    needed to implement IIS and a virtual web site for it to work).

    Let's recapitulate :

    So in the A.html page on server1 there is a form (form1) with a field
    (filed1) to be filled by an entry selected with lookfor.php. The call to the
    script lookfor is done thanks to window.open (below) :

    OnClick="javasc ript:winexp=win dow.open('http://server2/lookfor.php', ....);
    winexp.parent=s elf;" ...

    in the lookfor.php script (resident on Server2) there is a javascript code
    as below that should fill field1 on the form1 of the opener window
    window.opener.f orm1.field1.val ue=fileselected byuser;

    AND NOW... THE PROBLEM...

    here is the question
    When both the page and the script are on the same server, this is running
    perfectly but if i use 2 servers as discribed up the field is never filled.
    It seems as if window.opener.f orm1.field1.val ue=fileselected byuser; makes an
    exception a terminate the code (and the field1 is not filled). It also seems
    as if the object Windows.opener doesn't exists !

    Do you really think that it is a problem of 2 servers ? Is it possible to
    make it run ? Did i forget a piece of code ?

    Hope i was clear and you'll be able to help me. I can send you the code if
    you need it !

    Many thanks for yout help
    Fabrice

    PS : Please excuse my bad english.


  • Douglas Crockford

    #2
    Re: Hard to find problem for specialists !

    Fabrice Labrousse wrote:
    [color=blue]
    > Hello,
    >
    > Here is a hard problem i cannot solve about window.opener method
    > I think you'll need to be a specialist to find the solution... i can't find
    > the solution by myself ! Please help me.
    > Here is the problem (quiet complicated to explain).
    >
    > I use two differents servers with two IIS 4.0 Web servers
    >
    > On the first one (let's name it Server1) i got my web site. On my web site,
    > i have a page (A.html) that calls (in javascript) a new window that loads a
    > PHP script that remains on the second server. Are you following me ?
    >
    > On the second server (let's name it Server2) there is the so-called PHP
    > script "lookfor.ph p" that browse the system file of my server (of course i
    > needed to implement IIS and a virtual web site for it to work).
    >
    > Let's recapitulate :
    >
    > So in the A.html page on server1 there is a form (form1) with a field
    > (filed1) to be filled by an entry selected with lookfor.php. The call to the
    > script lookfor is done thanks to window.open (below) :
    >
    > OnClick="javasc ript:winexp=win dow.open('http://server2/lookfor.php', ....);
    > winexp.parent=s elf;" ...
    >
    > in the lookfor.php script (resident on Server2) there is a javascript code
    > as below that should fill field1 on the form1 of the opener window
    > window.opener.f orm1.field1.val ue=fileselected byuser;
    >
    > AND NOW... THE PROBLEM...
    >
    > here is the question
    > When both the page and the script are on the same server, this is running
    > perfectly but if i use 2 servers as discribed up the field is never filled.
    > It seems as if window.opener.f orm1.field1.val ue=fileselected byuser; makes an
    > exception a terminate the code (and the field1 is not filled). It also seems
    > as if the object Windows.opener doesn't exists !
    >
    > Do you really think that it is a problem of 2 servers ? Is it possible to
    > make it run ? Did i forget a piece of code ?[/color]

    You are running into the Same Source Rule. The windows can only interact
    if they were served from the same domain. You can get around it by
    putting this in a script in the head of all documents:

    document.domain = "common.com "

    If you do that, then windows from server1.common. com and
    server2.common. com can interact.


    Comment

    • Fabrice Labrousse

      #3
      Re: Hard to find problem for specialists !

      Douglas,

      thank you very much for your help... i didn't know this method. I ran it
      with success. All is important to note is that there mus be a equal suffix
      in the domain name for it to work.

      Regards.
      Fabrice

      "Douglas Crockford" <nospam@covad.n et> a écrit dans le message news:
      78b33$402509e3$ 436562a9$21930@ msgid.meganewss ervers.com...[color=blue]
      > Fabrice Labrousse wrote:
      >[color=green]
      > > Hello,
      > >
      > > Here is a hard problem i cannot solve about window.opener method
      > > I think you'll need to be a specialist to find the solution... i can't[/color][/color]
      find[color=blue][color=green]
      > > the solution by myself ! Please help me.
      > > Here is the problem (quiet complicated to explain).
      > >
      > > I use two differents servers with two IIS 4.0 Web servers
      > >
      > > On the first one (let's name it Server1) i got my web site. On my web[/color][/color]
      site,[color=blue][color=green]
      > > i have a page (A.html) that calls (in javascript) a new window that[/color][/color]
      loads a[color=blue][color=green]
      > > PHP script that remains on the second server. Are you following me ?
      > >
      > > On the second server (let's name it Server2) there is the so-called PHP
      > > script "lookfor.ph p" that browse the system file of my server (of course[/color][/color]
      i[color=blue][color=green]
      > > needed to implement IIS and a virtual web site for it to work).
      > >
      > > Let's recapitulate :
      > >
      > > So in the A.html page on server1 there is a form (form1) with a field
      > > (filed1) to be filled by an entry selected with lookfor.php. The call to[/color][/color]
      the[color=blue][color=green]
      > > script lookfor is done thanks to window.open (below) :
      > >
      > > OnClick="javasc ript:winexp=win dow.open('http://server2/lookfor.php',[/color][/color]
      .....);[color=blue][color=green]
      > > winexp.parent=s elf;" ...
      > >
      > > in the lookfor.php script (resident on Server2) there is a javascript[/color][/color]
      code[color=blue][color=green]
      > > as below that should fill field1 on the form1 of the opener window
      > > window.opener.f orm1.field1.val ue=fileselected byuser;
      > >
      > > AND NOW... THE PROBLEM...
      > >
      > > here is the question
      > > When both the page and the script are on the same server, this is[/color][/color]
      running[color=blue][color=green]
      > > perfectly but if i use 2 servers as discribed up the field is never[/color][/color]
      filled.[color=blue][color=green]
      > > It seems as if window.opener.f orm1.field1.val ue=fileselected byuser;[/color][/color]
      makes an[color=blue][color=green]
      > > exception a terminate the code (and the field1 is not filled). It also[/color][/color]
      seems[color=blue][color=green]
      > > as if the object Windows.opener doesn't exists !
      > >
      > > Do you really think that it is a problem of 2 servers ? Is it possible[/color][/color]
      to[color=blue][color=green]
      > > make it run ? Did i forget a piece of code ?[/color]
      >
      > You are running into the Same Source Rule. The windows can only interact
      > if they were served from the same domain. You can get around it by
      > putting this in a script in the head of all documents:
      >
      > document.domain = "common.com "
      >
      > If you do that, then windows from server1.common. com and
      > server2.common. com can interact.
      >
      > http://www.crockford.com/#javascript[/color]


      Comment

      Working...