Window.Open in chrome打开popus和new选项卡

时间:2022-10-22 15:02:51

I have a strange problem in chrome, I am using window.open to open a new tab and create a pdf using tcpdf and then send it as attachment to a specific address, now in chrome what happens is that it sends 2 mails. If popup is enabled then I get 2 window actions 1. Popup and 2. New Tab, firstly I don't understand how is that possible, I have never seen this.

我在chrome中有一个奇怪的问题,我使用window.open打开一个新选项卡并使用tcpdf创建一个pdf,然后将其作为附件发送到特定地址,现在在chrome中发生的是它发送2封邮件。如果弹出启用,那么我得到2个窗口动作1.弹出和2.新标签,首先我不明白这是怎么可能的,我从来没有见过这个。

Then If is disable the popup, it only opens in new tab, but still 2 mails.

然后,如果禁用弹出窗口,它只会在新选项卡中打开,但仍然是2封邮件。

Code used to call the popup page and email code is mentioned below. Please help.

用于调用弹出页面和电子邮件代码的代码如下所述。请帮忙。

window.open('/loancal/rhexportemail.php' + qstring,"_blank");
//Code used to open popup 

//------------- EMAIL CODE ----------------//
$to = "someone@gamil.com";
$from = "info@mydomain.com";
$subject = "Loan Enquiry Calculation Cashback - " . $client;
$message = "Please find attached Loan Enquiry Calculation Cashback statement for ".$client."."  ;

//a random hash will be necessary to send mixed content
$separator = md5(time());

// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;

// attachment name
$filename = $subject.".pdf";

// encode data (puts attachment in proper format)
$pdfdoc = $pdf->Output('LECC'.$separator.'.pdf', 'S');
$attachment = chunk_split(base64_encode($pdfdoc));

// encode data (multipart mandatory)
 $headers = "From: ".$from.$eol;
 $headers .= "MIME-Version: 1.0".$eol;
 $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
 $headers .= "Content-Transfer-Enconding: 7bit".$eol; 
 $headers .= "This is a MIME encoded message.".$eol.$eol;

 // message
 $headers .= "--".$separator.$eol;
 $headers .= "Content-Type: text/html; charsrt=\"iso-8859-1\"".$eol;
 $headers .= $message.$eol.$eol;

 // attachment
 $headers .= "--".$separator.$eol;
 $headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
 $headers .= "Content-Transfer-Encoding: base64".$eol;
 $headers .= "Content-Disposition: attachment".$eol.$eol;
 $headers .= $attachment.$eol.$eol;
 $headers .= "--".$separator."--";

 // send message
 if(@mail($to, $subject, $message, $headers))
 {

echo "<script type='text/javascript'> alert('mail sent');window.close();</script>";

 }
 else{
echo "<script type='text/javascript'>alert('mail not sent');window.close();  </script>";
  }

1 个解决方案

#1


0  

I strongly believe that you somehow call this twice.

我坚信你以某种方式称之为两次。

#1


0  

I strongly believe that you somehow call this twice.

我坚信你以某种方式称之为两次。