document.writeln - js ?
- Started
- Last post
- 6 Responses
- xrusos
how do i get javascript to call a .js file rather than a script tag from the top?
the call tag in the body has document.writeln. I think it's somewhere in there. can you help?
- kpl0
[script src="blah.js" type="text/javascript"]
?
- jevad0
can I see the js?
- xrusos0
i know that kpl... but for some reason, since the call tag won't let it work that way.
here's the script as i have in the head tag...
// JavaScript to interpolate random images into a page.
var ic = 11; // Number of alternative images
var xoxo = new Array(ic); // Array to hold filenamesxoxo[0] = "/images/highlanders.jpg";
xoxo[1] = "/images/car.jpg";
xoxo[2] = "/images/broken_dock.jpg";
xoxo[3] = "/images/lighthouse.jpg";
xoxo[4] = "/images/bird.jpg";
xoxo[5] = "/images/red_barn.jpg";
xoxo[6] = "/images/deck.jpg";
xoxo[7] = "/images/fog.jpg";
xoxo[8] = "/images/subway.jpg";
xoxo[9] = "/images/highlanders.jpg";
xoxo[10] = "/images/highlanders.jpg";function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
}
}
// Write out an IMG tag, using a randomly-chosen image name.
var choice = pickRandom(ic);
- xrusos0
and here's the call tag...
[SCRIPT LANGUAGE="JavaScript"]document.w... type=text/css]#billboard {background-image:url('+xoxo[cho...
blasted carrots and NT!
- xrusos0
right now i have to include the actual script in the top of every page i want it to work on. it won't let me just do what you said, kpl, and move it to a file. it just stops working when i do that.
- jevad0
try putting
onLoad="pickRandom(range);"
in your body tag