0

問題が 1 つあります。ポップアップがあり、ユーザーがポップアップでルームを作成した後、そのポップアップを閉じてから、オープナー ウィンドウを新しい URL にリダイレクトしたいと考えています。関数を呼び出す方法がわからないことを除いて、関数とすべてを持っています。(以下に、関数をロードする場所を書きました)。

ありがとう

<?php session_start(); ?>
<script type="text/javascript">
 function CloseAndRefresh() 
  {
opener.location.href = "<?php echo $website_url; ?>/livechat.php?idim=<?php echo $perdorusi2; ?>&room=<?php echo $emri; ?>";
opener.focus();
self.close();
  }
</script>
<?php
        include_once('db.php');

$perdoruesi = $_GET['perdoruesi']; 
if( strlen($_SESSION['id']) > '0' ) { $perdorusi2 = $_SESSION['id']; } else { $perdorusi2 = $perdoruesi; }

function makeRandomString($max=8) {
    $i = 0; 
    $possible_keys = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $keys_length = strlen($possible_keys);
    $str = ""; 
    while($i<$max) {
        $rand = mt_rand(1,$keys_length-1);
        $str.= $possible_keys[$rand];
        $i++;
    }
    return $str;
}

$emri = makeRandomString();


$hidhnedb = mysql_query("INSERT INTO dbname(`row1`, `row2`) VALUES(NULL, '$emri')");

if($hidhnedb) { 

$max=count($_SESSION['mysession']);
$i = $max + 1;
$_SESSION['mysession'][$i][$emri] = $emri;

?>
***Here is the the place where I want to call the javascript function but I do not know how to do that.***
<?php
} else { echo "Error!"; } 


?>
4

3 に答える 3

1

「ポップアップ」と名付けたものは明確ではありません。別のブラウザ ウィンドウですか? window.confirm または window.alert ダイアログ? jQueryUITwitter Bootstrapのようなポップアップ?

ブラウザウィンドウだとしましょう。

次の 2 つの可能性があります。

1 - ポップアップを閉じるボタンを 1 つ作成します。

<button onClick="CloseAndRefresh()">Close</button>

2 - N 秒後に自動的にトリガーします。

<script type="application/javascript">
   var n = 5; 
  setTimeout(CloseAndRefresh, 1000*n);
</script>
于 2013-08-21T21:48:00.740 に答える