Important alert: (current site time 7/15/2013 1:11:21 PM EDT)
 

VB icon

Dynamic Content 2.0

Email
Submitted on: 6/14/2002 10:16:36 AM
By: Premshree Pillai  
Level: Intermediate
User Rating: By 3 Users
Compatibility: JavaScript
Views: 6216
 
     This JavaScript displays different content for different links on the same area, dynamically.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Dynamic Content 2.0
' Description:This JavaScript displays different content for different links on the same area, dynamically.
' By: Premshree Pillai
'
' Assumes:This JavaScript displays different content for different links on the same area, dynamically. 
You can display any content in the area. The function is called like this » 
<a href="javascript:void(0);" onClick="javascript:showContent('<font face=verdana,arial,helvetica>This is Content 1</font>');"><font face="verdana,arial,helvetica" color="#CC0000" size="-1"><b>Content 1</b></font></a> 
The content marked bold above is the content that you want to display when a link is clicked. You can include <HTML> tags also. So you can even include images. 
This version (v 2.0) supports IE, NS4, NS6.
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2983&lngWId=14'for details.'**************************************

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dynamic Content 2.0</title>
<style type="text/css">
.link{font-family:verdana,arial,helvetica; font-size:8pt; color:#404040; font-weight:normal; text-decoration:underline}
.link:hover{font-family:verdana,arial,helvetica; font-size:8pt; color:#CC0000; font-weight:normal; text-decoration:underline}
.header{font-family:verdana,arial,helvetica; font-size:22pt; color:#404040; font-weight:bold; text-decoration:none}
</style>
</head>
<body bgcolor="#FFFFFF">
<center><span class="header">Dynamic Content 2.0</span></center><br>
<!-------------------------------------------------------------------------------------->
<!--BEGIN DYNAMIC CONTENT 2.0-->
<script language="JavaScript1.2">
//-----------------------------------------------
// Dynamic Content 2.0 |
// Now supports IE, NS4, NS6|
// (c) 2002 Premshree Pillai|
// Web : http://www.qiksearch.com|
// E-mail :premshree@hotmail.com|
// Use freely as long as this message is intact |
//-----------------------------------------------
// Location of script : http://www.qiksearch.com/javascripts/dynamic-content20.htm
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1;
var ns6=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1;
var ns4=document.layers;
function showContent(content)
{
 if(ie4)
 {
 showContentObj=document.all.qiksearch_div;
 }
 if(ns6)
 {
 showContentObj=document.getElementById("qiksearch_div");
 }
 if(ie4||ns6)
 {
 if(showContentObj.innerHTML!=content)
 {
showContentObj.innerHTML=content;
 }
 else
 {
showContentObj.innerHTML="";
 }
 }
 if(ns4)
 {
 document.nsdiv.document.write(content);
 document.nsdiv.document.close();
 }
}
</script>
<center>
<a href="javascript:void(0);" onClick="javascript:showContent('<font face=verdana,arial,helvetica>This is Content 1</font>');"><font face="verdana,arial,helvetica" color="#CC0000" size="-1"><b>Content 1</b></font></a> | <a href="javascript:void(0);" onClick="javascript:showContent('<font face=verdana,arial,helvetica>This is Content 2</font>');"><font face="verdana,arial,helvetica" color="#CC0000" size="-1"><b>Content 2</b></font></a> | <a href="javascript:void(0);" onClick="javascript:showContent('<font face=verdana,arial,helvetica>This is Content 3</font>');"><font face="verdana,arial,helvetica" color="#CC0000" size="-1"><b>Content 3</b></font></a>
<br><br><layer id="nsdiv" left="310"></layer>
<div id="qiksearch_div"></div></center>
<!--END DYNAMIC CONTENT 2.0-->
<!-------------------------------------------------------------------------------------->
<br><table align="center" width="400" cellspacing="0"><tr><td>
<font face="verdana,arial,helvetica" size="-1" color="#404040">
This JavaScript displays different content for different links on the same area, dynamically.
<br><br>
You can display any content in the area. The function is called like this »
<br><br><font face="courier"><a href="javascript:void(0);" onClick="javascript:showContent('<b><font face=verdana,arial,helvetica>This is Content 1</font></b>');"><font face="verdana,arial,helvetica" color="#CC0000" size="-1"><b>Content 1</b></font></a></font>
<br><br>The content marked bold above is the content that you want to display when a link is clicked. You can include <HTML> tags also. So you can even include images.
<br><br>This version (<b>v 2.0</b>) supports IE, NS4, NS6.
</font>
<hr width="100%" style="height:1px; color:#CC0000">
</td></tr></table>
<center><a href="http://www.qiksearch.com" class="link">© 2002 Premshree Pillai. All rights reserved.</a></center>
</body>
</html>


Other 28 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
10/6/2003 12:42:09 PM

Hi!

Your code could be very useful for me, if the content submitted via the link also could be other than innerHTML. Like an image. How so?
(If this comment was disrespectful, please report it.)

 
8/1/2004 1:38:09 AMRde

innerHTML = <IMG SRC="">
(If this comment was disrespectful, please report it.)

 
8/1/2004 1:44:59 AMRde

Thanks for sharing this. Happy scripting, Rd :)
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.