2017-05-11 57 views
0

我有2頁:A.htm和B.htm A調用B作爲彈出窗口,然後在一些操作之後B必須調用A內的JavaScript,爲此我使用了javascript :「揭幕戰」。從呼叫者頁面的彈出窗口執行javascript

,但我覺得我做了,因爲,在彈出的一些錯誤,當我按一下按鈕沒有發生,這裏的例子下載:http:\www.suale.it/prova/a.zip

這是這個a.htm

<html> 
<script language="javascript"> 


      function ricaricapagina() 
      { 
       var theform; 
       if 
       (
        window.navigator.appName.toLowerCase().indexOf("netscape") > -1) { 
        theform = document.forms["frmMain"]; 
       } 
       else 
       { 
        theform = document.frmMain; 
       } 

       //txtOperation.value=pOperation; 
       theform.submit(); 
      } 

      function SelectArticoli(pForm, txtOperation) 
      { 
       var sQueryString=new String; 
       var WinSettings = "center=yes,resizable=yes,scrollbars=yes,height=600,width=1000"; 
       sQueryString='B.htm'; 
       sQueryString += '?CallerForm=' + pForm; 
       sQueryString += '&CallerOperation=' + txtOperation; 
       sQueryString += '&CallerReload=1' ; 

        window.open(sQueryString, '', WinSettings); 
      } 

</script> 
<form name="frmMain" id="frmMain" action="A.htm" method="post"> 
<input name="txtOperation" type="hidden" id="txtOperation" /> 

<input name="cmdSelectArticoli" id="cmdSelectArticoli" onclick="javascript:SelectArticoli('frmMain', 'txtOperation');" type="button" value="Aggiungi Articoli..."> 

</form> 

</html> 

此的代碼是B.htm

<html> 
<script language="javascript"> 

      function chiudipopup(pResult) 
      { 

       if (pResult==true) 
       { 

        window.opener.document.forms[frmMain].item(frmMain.txtCallerOperation.value).value = 'SelectArticoli';     


        if (frmMain.txtCallerReload.value != '') 
        { 
         window.opener.ricaricapagina(); 
        } 
       } 

       window.close(); 
      } 

    </script> 

</script> 
<form name="frmMain" method="post" id="frmMain"> 
    <input name="txtCallerOperation" type="hidden" id="txtCallerOperation" value="txtOperation" /> 

    <input type="submit" name="cmdConferma" onclick="javascript:chiudipopup(true);" value="conferma" id="cmdConferma" class="button" /> 

</form> 

</html> 

回答

0

可以嘗試聲明功能window.ricaricapagina =()函數的代碼{...}

0

你有兩個問題:

  1. [B.html] =>變化window.opener.document.forms[frmMain].item(frmMain.txtCallerOperation.value).valuewindow.opener.document.forms["frmMain"].elements["txtOperation"].value
  2. [B.html] =>window.opener.ricaricapagina();(我的工作就可以了:))