将存储在变量中的url调用到javascript中

时间:2016-04-02 12:59:55

标签: javascript php url redirect

$id = $_POST['id'];
$to="codieboi@mail.com";
$msg1="done";
$email_subject = "View Cateloge Request";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'X-MSMail-Priority: High'. "\r\n";
$headers = 'From: '.$_POST['email']."\r\n".
'X-Mailer: PHP/' . phpversion();
$email_message .= "Name: ".$_POST['fname']."\n";
$email_message .= "Email: ".$_POST['email']."\n";
$email_message .= "Phone: ".$_POST['phone']."\n";
$email_message .= "Phone: ".$_POST['message']."\n";

@mail($to, $email_subject, $email_message, $headers);  
$link = the_field('upload_file', $id);
echo '<script type="text/javascript">var url="_________";var win = window.open(url, "_blank");win.focus();</script>';

我将动态存储到变量&#34; link&#34;。邮件发送后,我想在新标签中打开它。这是我写的代码。我需要将网址放在_____________。

请帮忙。

1 个答案:

答案 0 :(得分:0)

如果您将网址存储到可变链接,只需使用它:

echo "<script type='text/javascript'>var url='". $link."';var win = window.open(url, '_blank');win.focus();</script>";