javascript - Why is my onclick script not changing my innerhtml? -


i have simple webpage took template. on right have list of links in div , when clicking on them want html page located on server load in inner div area. when clicking on link, nothing happens. i've tried setting innerhtml text value in case src part invalid, nothing. missing? looks examples i've gone through.. , note i'm giving partial html, know body isn't closed etc.

i have:

<body>   <script>     function results()     {       document.getelementsbyclassname('mid-left-container').innerhtml="src="..\vrs_bvt\vrs_test.html""     }   </script>    <div id="main-wraper">     <div id="top-wraper">       <div id="banner">automation server</div>      </div>     <div id="mid-wraper">       <div class="mid-wraper-top">         <div class="mid-leftouter">           <div class="mid-left-container">             blah blah           </div>         </div>         <div class="right-container">           <div class="right-container-top">             <h3><span class="yellow-heading">projects</span></h3>             <ul>               <li><a href="#" onclick="results()">vrs bvt</a></li>             </ul>           </div>         </div>       </div>     </div>   </div> </body> 

getelementsbyclassname() returns array (actually nodelist) of matching elements.

you're creating new innerhtml property on array, has no effect.

instead, need actual element array , set innerhtml:

document.getelementsbyclassname(...)[0].innerhtml = ... 

also, string literal invalid syntax.
need use single-quotes or escape double-quotes.

also, putting src="..\vrs_bvt\vrs_test.html" in content of html element not load server.
need use ajax or <iframe>.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -