First, I want to call out a .js file from inside a web page to write some stuff. I've done it before, but it's been a while. I've got it ultra-simplified just to try to get it to work. (Once I've got the bugs out, I'm going to put some real code in the .js file.)
[HTML]
This is what's in my web page:
<div id=content>
<p>
<script type="text/javascript" src=”outback.js ”></script>
</p>
</div>
[/HTML]
-------------------------
Here's the content of outback.js:
Expand|Select|Wrap|Line Numbers
- document.writeln("We went to the outback.");
When I refresh the web page, nothing appears (except what is actually written inside the page). If I get rid of the reference to outback.js and put the writeln statement inside the <script></script> tags, I get what I want. But I don't want to do that because ... here's the second, advanced question:
I would like to be able to swap out the text that's inside of those <div></div> tags, based on a function triggered by an onClick event in another div. So, I want to have a little menu and based on what someone clicks ("outback", "daintree", "whitsunday s", etc.), they get different text (and more things to click on) in the "content" div.
The question is whether this is possible -- I have read that you can't change text in an existing page, but why can't you? You can change images. I've already got my page set up so that when you click different links in one div, you see different images in another div. I just want to modify the swap-out function that changes the images so that it changes the reference to the .js file.
So,
First question: Why can't I get the writeln command to execute when it's in the .js file?
Second question: Can I swap out the contents of a .js file within a given div?
Thanks for any assistance.