2017-08-08 71 views
0

javascript函數不顯示錨標記

let css_pdf_zero = ['cssFoundations.pdf', 'cssCookBook.pdf']; 
 
      
 
      function pdf_load_zero(pdf, path){ 
 
      path = path || 'pdf-testing/'; // default path here 
 
       var pdfAnchor = '<a href="' + path + '" alt = "">' + '</a>'; 
 
       document.write(pdfAnchor); document.close(); 
 
      } 
 
      $('#tabs-one1').html(pdf_load_zero(css_pdf_zero));
誰能告訴我什麼是錯的代碼?

+0

什麼是你想用文件撰寫完成? –

+0

是的,這只是一個錯誤,但即使它仍然不起作用,如果你刪除它 –

回答

0

這更接近你想要做什麼?

let css_pdf_zero = ['cssFoundations.pdf', 'cssCookBook.pdf']; 
 
      
 
function pdf_load_zero(pdf, path){ 
 
    path = path || 'pdf-testing/'; // default path here 
 
    var pdfAnchor = '<a href="' + path + '" alt="">Text</a>'; 
 
    $('#tabs-one1').html(pdfAnchor); 
 
} 
 

 
pdf_load_zero(css_pdf_zero);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="tabs-one1"></div>

+0

是的,但它跳轉到這個窗口說,在頂部/ pdf測試指數,有沒有辦法可以在一個單獨的窗口中打開PDF讀書。 –

+0

請參閱:https://stackoverflow.com/questions/17711146/how-to-open-link-in-new-tab-on-html –