2012-04-11 6 views
2

Onclickイベント中にLoad_content()内に置いたドキュメントタイトルをロードするために、この垂直リストを取得しようとしています。満足のいく結果は、私はあなたのコード内のいくつかの誤字を持っているのiframeにPDFをiFrameに読み込む垂直リストを取得するには

<html> 
<head> 
    <title> Literature of Andrew Willis 
    </title> 

    <link rel="stylesheet" href="mycss.css" type="text/css" /> 
    <link rel="stylesheet" type="text/css" href="css/cssverticalmenu.css" /> 


    <script language="javascript" type="text/javascript"> 

    function load_content (link) { 
    document.getElementById("iframe").setAttribute("src","link"); 
    } 

    </script> 

</head> 
<body> 


    <div id="logo"> 
     <a href="#"><img src="mainlogo.jpg" height=100 width=400></a> 
    </div> 


    <div id="content"> 

     <div id="leftcolumn"> 

      <ul class="glossymenu"> 
       <li><a href="#" onclick="load_content(Look at me now.pdf)">Short Essays</a></li> 
       <li><a href="#" onclick="load_content(hangmansdog.pdf)" >Poetry</a></li> 
        <li><a href="http://www.pourinpourout.com" >Blog</a></li> 
      </ul> 
     </div> 
     <div id="rightcolumn"> 
      <div id="content"> 
      <iframe id="iframe1" src="#"></iframe> 
      </div> 
     </div> 
    </div> 
</body> 

答えて

0

を新しいリンク...新しいPDF負荷をクリックすると、そのたびになります。 iframeに "iframe1"のIDを渡しましたが、 "iframe"を使用してJSで参照しました。あなたは変数としてそれを使用しているので、あなたはまた、リンクの前後に引用符を持つべきではありません、13行は次のようになります。

document.getElementById("iframe1").setAttribute("src",link); 

あなたはしかし、おそらくあなたがに行くときのリンクの周りに自分自身を単一引用符を置くことになるでしょうそれらをリンクする。すなわちonclick="load_content('Look at me now.pdf')"

関連する問題