2014-09-04 230 views
-2

我正在使用php。打开新窗口

function as_pdf_link($strContent) 
{ 
    global $wp_query; 

    $strHtml = ' 
     <div id="aspdf"> 
      <a href="' . get_bloginfo('wpurl') . '/wp-content/plugins/as-pdf/generate.php?post=' . $wp_query->post->ID .'"> 
       <span>' . stripslashes(get_option('as_pdf_linktext')) . '</span> 
      </a>  
     </div>'; 

    return $strContent . $strHtml; 
} 

当用户点击链接时,generate.php将被处理。

我想用新窗口显示使用javascript从这些PHP代码返回的结果。

我该怎么办?

+0

刚将'target =“new”'添加到您的锚点()标记? – 2014-09-04 04:40:27

回答

1

使用target="_blank"

<a target="_blank" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/as-pdf/generate.php?post=' . $wp_query->post->ID .'"> 
      <span>' . stripslashes(get_option('as_pdf_linktext')) . '</span> 
     </a> 

看一看target="_blank" vs. target="_new"

在新窗口使用javascript:DEMO

onclick="return fun(this);" 

功能:

function fun(that){ 
    console.log(that.href); 
    window.open(that.href, "New Window", "height=600,width=600"); 
    return false; 
} 
+0

它在当前打开浏览器的新选项卡中显示。我想用新的开放浏览器来显示它。 – 2014-09-04 04:45:45