Okay, I have a clas assignment I’ve been working on all semester, and I’m almost done, but then THIS happened. I finished the .htm file, but, the objects, suitcases and… bags, I think, won’t let me drag them. Also, the text is all spaced out and wrong. Can someone look over my code?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Nomad Outfitters of Paradise Mountain: Tents Page</title>
<meta name="keywords" content="Mountain climbing, Outdoor adventures, Estes Park, Outfitters and guides, experienced mountain guides, rugged vacations,
Paradise Mountain Famly Resort" />
<meta name="description" content="Nomad Outfitters provides experienced guides and coordinates overnight, weekend, and week-long outdoor adventures for
guests of Paradise Mountain Family Resort." />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="nomad.css" rel="stylesheet" type="text/css" />
<style>
<!–
.tenthead {
font-family: arial, sans-serif;
font-size: 14pt;
}
.button {
font-family: impact, arial, sans serif;
font-size: 8pt;
}
.norm {
font-weight: normal;
}
.noital {
font-style: normal;
}
#logo {
position: absolute; top: 0px; left: 0px;
}
#head {
position: relative; left: 250px; top: 20px;
}
.tentbody {
width: 80%;
}
#backtext {
position: absolute; left: 250px; top: 12px;
font-size: 64pt; font-family: arial; color: #9999FF;
z-index: -1;
}
#list {
height: 300px; width: 85%;
overflow: scroll;
–>
<style>
#sidebar {
width: 40%; float: right;
font-family: arial; font-size: 11pt; background: #99CC99;
}
.exp1 {
width: 375px;
}
#pack1 {
position: absolute; left: 505px;
}
#pack1 {
position: absolute; left: 535px;
}
#pack1 {
position: absolute; left: 425px;
}
#pack1 {
position: absolute; left: 460px;
}
#bag1 {
position: absolute; left: 565px;
}
#bag2 {
position: absolute; left: 670px;
}
.drag {
z-index: 10px;
}
–>
</style>
<script type="text/javascript" language="JavaScript">
<!–
totalTents = 0;
function countHeaders() {
for (var i = 0; i < document.all.length; i++){
var el = document.all[i].name;
if ("tent" == el){
totalTents++;
}
}
}
function reCount() {
totalTents–
textnum.innerHTML=totalTents
}
function cycle(el, text, time) {
if (el.selNum == null) {
el.texts = new Array();
el.currText = "";
el.currNum = 0;
el.selNum = 0;
el.length = 0;
for (el.i = 0; el.i < text.length; el.i++) {
if (text.charAt(el.i) == ",") {
el.texts[el.currNum] = el.currText;
el.currText = "";
el.currNum++;
el.i++;
}
el.currText = el.currText + text.charAt(el.i);
}
el.texts[el.currNum] = el.currText;
el.length = el.currNum;
}
if (el.selNum < el.length) {
el.selNum = el.selNum + 1;
} else {
el.selNum = 0;
}
{
el.innerHTML = el.texts[el.selNum];
}
ab1 = window.setTimeout("cycle(" + el.id + ",’" + text + "’," + time + ");", time * 100);
}
var elDrag = null
function movePointer() {
if ((1 == event.button) && (elDrag != null)) {
var iTop = event.clientY + document.body.scrollTop
var iLeft = event.clientX + document.body.scrollLeft
var iLessTop = 0
var iLessLeft = 0
var elCurr = elDrag.offsetParent
while (elCurr.offsetParent != null) {
iLessTop += elCurr.offsetTop
iLessLeft += elCurr.offsetLeft
elCurr = elCurr.offsetParent
}
elDrag.style.pixelTop = iTop – iLessTop – elDrag.y
elDrag.style.pixelLeft = iLeft – iLessLeft – elDrag.x;
event.returnValue = false
}
}
function checkDrag(elCheck) {
while (elCheck != null) {
if (null != elCheck.getAttribute("canDrag"))
return elCheck
elCheck = elCheck.parentElement
}
return null
}
function butPress() {
var elCurr = checkDrag(event.srcElement)
if (null != elCurr) {
elDrag = elCurr
elDrag.x = event.offsetX
elDrag.y = event.offsetY
var op = event.srcElement
if ((elDrag != op.offsetParent) && (elDrag != event.srcElement)) {
while (op != elDrag) {
elDrag.x += op.offsetLeft
elDrag.y += op.offsetTop
op = op.offsetParent
}
}
}
}
function checkIt() {
return (null == checkDrag(event.srcElement) && (elDrag!=null))
}
document.onmousedown = butPress
document.onselectstart = checkIt
document.onmousemove = movePointer
document.ondrag
I know near to nothing about Javascript but I think you may want to close the frist <style> tag and possibly the
<script type="text/javascript" language="JavaScript"> tag.
Maybee try validating the code at w3schools
Hope this helps