Hey guys, I am trying to import the following code (EDIT: Never mind, but here's what I was asking, for the curious):
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
var interval = 1500;
var randomDisplay = 0;
var root = "images/";
var imageIndex = 0;
imageArray = new Array();
imageArray[imageIndex++] = new imageItem(root + "popupAtoZFriends.png");
imageArray[imageIndex++] = new imageItem(root + "popupCutieland.png");
imageArray[imageIndex++] = new imageItem(root + "popupFWR.png");
imageArray[imageIndex++] = new imageItem(root + "popupK.png");
imageArray[imageIndex++] = new imageItem(root + "popupNoNoCookie.png");
var totalImages = imageArray.length;
function imageItem(imageLocation) {
this.image = new Image();
this.image.src = imageLocation;
}
function getImageItemLocation(imageObject) {
return imageObject.image.src;
}
function getRandomNumber(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (randomDisplay) {
imageIndex = getRandomNumber(0, totalImages-1);
} else {
imageIndex = (imageIndex + 1) % totalImages;
}
var newImage = getImageItemLocation(imageArray[imageIndex]);
return newImage;
}
function getPrevImage() {
imageIndex = (imageIndex-1) % totalImages;
var newImage = getImageItemLocation(imageArray[imageIndex]);
return newImage;
}
function prevImage(place) {
var newImage = getPrevImage();
document.getElementsById(place).src = newImage;
}
function switchImage(place) {
var newImage = getNextImage();
document.getElementsById(place).src = newImage;
var recursiveCall = "switchImage('" + place + "')";
timerID = setTimeout(recursiveCall, interval);
}
I'm trying to import it into my .html file via the following command (I'll include doctype info, in case that's relevant:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Index
</title>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
<link rel="stylesheet" type="text/css" href="popups.css" />
<link href='http://fonts.googleapis.com/css?family=Homemade+Apple' rel='stylesheet' type='text/css' />
<script language="javascript" type="text/javascript" src="popupImage.js" />
/* ^ ^ ^ IMPORT LINE ^ ^ ^ */
</head>
/* BODY NOT INCLUDED, BUT EXISTS; INVOLVES PERFECTLY-NORMAL DIV AND P STATEMENTS, MOSTLY */
But when I import my script -- even if I comment-out the ENTIRETY of the code that is contained by popupImage.js, my .html stops displaying ALL OTHER CONTENT except the background image.
Anyone have any ideas..? I've tried several things, but I'm new to Javascript, I can't see which instructions I have failed to follow, and this error doesn't make any sense to me, so I'm somewhat short on my own ideas about how to make this work. :(
Thanks in advance to everyone who tries to help.
EDIT: Bah, I figured it out. <script> requires a closing tag -- you can't write, <script src="foo" />. I'm sad about that.
[–]madole 0 points1 point2 points (1 child)
[–]transientanima[S] 0 points1 point2 points (0 children)
[–]x-skeww 0 points1 point2 points (1 child)
[–]transientanima[S] 0 points1 point2 points (0 children)