Click here to Skip to main content
15,943,294 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
this code is for menu. if i click this menu; the div content can load the html page. by same thing i will click another menu; the same div content can load the another html page.
  <div align="center"><a href=# class="style15" onclick="divload()">IEEE Projects</a></div>

this is function code

<script type="text/javascript">
  function divload()
  document.getElementById("article").innerHTML = "test.html";

anyone help me...

First of all, a page cannot be a part of an element, by definition of a page. :-)

Of course, you can have any HTML content inside div element; and you almost got it. Only if you find an element by id, that element should have this id, in this case, "article". For example,
<div id="article" onclick="divload()">Click here...</div>

By the way, your attribute align="center" is quite a bad thing. You need to use CSS instead. Your naming like "style15" is also quite bad. How are you going to support it? All names should be semantically meaningful.

Share this answer
Espen Harlinn 18-Jul-12 11:07am    
Sergey Alexandrovich Kryukov 18-Jul-12 11:27am    
Thank you, Espen.
Berhanu sahle 1-Apr-15 4:44am    
this works but when i reload my browser, the div loses its can i fix it.....
Sergey Alexandrovich Kryukov 1-Apr-15 10:03am    
Of course. This is a good question. Please see Solution 2 for a detailed answer.
Next time, better ask a separate question.
Berhanu sahle asked:
this works but when i reload my browser, the div loses its data… how can i fix it…
Of course. If you need to preserve data, you need to serialize it, store it, and restore after the page is loaded. As the question is about pure HTML+JavaScript, the best universal way would be using local Web storage:

It is important to use session storage sessionStorage object, and not local storage. Local storage is permanent; and we don't want to contaminate local browser data. Now, another problem is: data stored by one key should be string, and I want to store the object encapsulating the states of both controls, one of these state values being Boolean. For this purpose, I utilized JSON serialization embedded in JavaScript:

I explain the solution in the section "Dynamic Strict Mode Switching and Web Storage" of my article JavaScript Calculator.

You will find a complete code sample covering this technique completely. You can also download the whole source code for the game, with is just two JavaScript files used in one HTML.

Congratulations with 1st of April! :-)

I would like to use the occasion to invite everyone to see my new 1 of April publication and have some fun:

Some Programming Approaches to "Neuro-Linguistic Programming".
Participation in this game in Comments and Discussions is especially encouraged.

Thank you.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900