View Full Version : help to change DIV content - want to put a javascript into the DIV

06-15-2005, 06:29 PM

I Need help changing the content of a DIV. I sincerely researched the
issue and have not found a solution except to scrap the idea and stick
with the iframe code that I had been using. My purpose here is to
avoid iframes.

I know how to change the DIV content to other basic html statements,
such as basic IMG's or Lists, but I want to put a Javascript into the
DIV, and have not found a way to do it.

The Javascript that I want to place into the DIV is a typical
tickerbox, and it is found at:

I saved the code for the tickerbox to a "tickerbox.js" file.

The relevant code:

(in Head...)

.box2 {width: 408px; height: 88px;}

function jumptodiv() {
document.getElementById("area2").innerHTML = ????



<DIV id="area2" style="box2">

<img src="someintroductionphoto.jpg">

<!-- the goal is to replace this photo with the Tickerbox
Javascript when user clicks the button below -->


<input type="button" value="About" onClick="jumptodiv()">

A working solution will be sincerely appreciated. Even an example of getting ANY javascript to work when poked into the DIV would be nice.

06-18-2005, 07:19 AM
style="box2" is meaningless, I think you mean class="box2"
OK, that out of the way, this worked:
<title>Bring On the Ticker - Demo</title>
.box2 {width: 408px; height: 88px;}
<script type="text/javascript">
function jumptodiv() {
<div class="box2">
<img id="pic" src="someintroductionphoto.jpg">
<span id="tick" style="display:none">
<script src="ticker.js" type="text/javascript"></script>
<input type="button" value="About" onClick="jumptodiv();">