2014-09-04 268 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