Monday, March 21, 2011

how change html content onclick menu

<html> <head> <title>Change iFrame Contents</title> <script language="JavaScript" type="text/javascript"> <!-- function changeFrame(newPage){ document.getElementById('myframe').src = newPage + ".html"; } //--> </script> </head> <body> <div align="center"> <span id="menu"> <a href="#" id="default" onClick="changeFrame(this.id)">Home</a> <a href="#" id="about" onClick="changeFrame(this.id)">About</a> <a href="#" id="contact" onClick="changeFrame(this.id)">Contact</a> </span> <br><br> <iframe src="default.html" id="myframe"> You can't see iFrames :( </iframe> </div> </body> </html>

Bind Some Event to Element and trigger that function when click the element

Scenario: Suppose if we used same click event function in various web pages. if you want do some logic some page button for that need to re...