PDA

View Full Version : IE vs NN6


Unregistered
03-31-2001, 01:54 AM
Kenny or anyone, I just can't seem to get this
script to work in NN6. Can you tell me what's
required to get this thing going..?

<HTML> <HEAD> <STYLE> .fly {
font-family: arial;
font-size: 24px;
color: #FFFFFF;
position: absolute;
visibility: hidden;
z-index: 2;
}

.logo {
font-family: times;
font-size: 72px;
color: #008000;
position: absolute;
top: 0px;
left: 30px;
visibility: visible;
z-index: 1;
}

.desc {
text-align: center;
font-family: arial;
font-size: 12px;
color: #009000;
position: absolute;
top: 220px;
left: 40px;
width: 400px;
visibility: hidden;
z-index: 0;
}

BODY {
background: #006000;
}

A {
color: #FFFFFF;
}

</style> <SCRIPT LANGUAGE = "JavaScript"> /* Show an object */
function showObject(object) {
object.visibility = VISIBLE;
}

/* Hide an object */
function hideObject(object) {
object.visibility = HIDDEN;
}

/* Slide the company logo from top to middle */
function slideLogo(from, to) {
if (from < to) {
company.top = (from += 10);
setTimeout('slideLogo(' + from + ',' + to + ')', 75);
}
else initObjects();
}

/* Rotate selected objects */
function rotateObjects() {
for (var i = 0; i < pos.length; i++) {
pos[i] += inc; objects[i].visibility = 'visible';
objects[i].left = (r * Math.cos(pos[i])) + xoff
objects[i].top = (r * Math.sin(pos[i])) + yoff;
}
rotateTimer = setTimeout("rotateObjects()", 75);
}

/* Initialize selected objects for rotation */
function initObjects() {
/* Here is the array of HTML elements that will be rotated, from fly1 to fly4
Just put the shortcut variables to the HTML elements in this little array
and they will be rotated automatically */
objects = new Array(fly1, fly2, fly3, fly4);
pos = new Array();
pos[0] = 0;
for (var i = 1; i < objects.length; i++) {
pos[i] = parseFloat(pos[i - 1] + ((2 * pi) / objects.length));
}
rotateObjects();
}

/* Variables for rotating objects */
var objects;
var pos;
var r = 160; // radius
var xoff = 180; // x offset
var yoff = 170; // y offset
var pi = Math.PI; // get pi
var inc = pi / 180; // degrees per rotation cycle
var objects; // objects to be rotated
var pos; // position for objects

</script> </HEAD> <BODY> <DIV ID = "fly1" CLASS = "fly"> <A HREF = "#" onMouseOver = "showObject(desc1)" onMouseOut = "hideObject(desc1)">About</A><BR> </DIV> <DIV ID = "fly2" CLASS = "fly"> <A HREF = "#" onMouseOver = "showObject(desc2)" onMouseOut = "hideObject(desc2)">News</A><BR> </DIV> <DIV ID = "fly3" CLASS = "fly"> <A HREF = "#" onMouseOver = "showObject(desc3)" onMouseOut = "hideObject(desc3)">Products</A><BR> </DIV> <DIV ID = "fly4" CLASS = "fly"> <A HREF = "#" onMouseOver = "showObject(desc4)" onMouseOut = "hideObject(desc4)">Partners</A><BR> </DIV> <DIV ID = "company" CLASS = "logo">The Company</DIV> <DIV ID = "desc1" CLASS = "desc"> Learn about our company's history, goals, and people.
</DIV> <DIV ID = "desc2" CLASS = "desc"> Read about what's happening with our company right now.
</DIV> <DIV ID = "desc3" CLASS = "desc"> See our catalog of products; photos, descriptions, and specs.
</DIV> <DIV ID = "desc4" CLASS = "desc"> Key business partners and strategic alliances.
</DIV> <SCRIPT LANGUAGE = "JavaScript"> /* Simple version detection */
var isNS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);
/* These constants were not discussed in the article. They can be used in place
of hidden and visible because on occasion Navigator has problems with the two */
var HIDDEN = (isNS) ? 'hide' : 'hidden';
var VISIBLE = (isNS) ? 'show' : 'visible';

/* Create shortcut variables for different absolutely positioned elements */
var fly1 = (isNS) ? document.fly1 : document.all.fly1.style;
var fly2 = (isNS) ? document.fly2 : document.all.fly2.style;
var fly3 = (isNS) ? document.fly3 : document.all.fly3.style;
var fly4 = (isNS) ? document.fly4 : document.all.fly4.style;
var company = (isNS) ? document.company : document.all.company.style;
var desc1 = (isNS) ? document.desc1 : document.all.desc1.style;
var desc2 = (isNS) ? document.desc2 : document.all.desc2.style;
var desc3 = (isNS) ? document.desc3 : document.all.desc3.style;
var desc4 = (isNS) ? document.desc4 : document.all.desc4.style;

/* Begin the sliding of the company logo */
slideLogo(0, 140);


</script> </BODY>

whkoh
03-31-2001, 02:04 AM
Line 1, column 1:
<HTML> <HEAD> <STYLE> .fly {
^
Error: Missing DOCTYPE declaration at start of document

Line 1, column 20:
<HTML> <HEAD> <STYLE> .fly {
^
Error: required attribute "TYPE" not specified

Line 42, column 40:
</style> <SCRIPT LANGUAGE = "JavaScript"> /* Show an object */
^
Error: required attribute "TYPE" not specified

Line 96, column 16:
</script> </HEAD> <BODY> <DIV ID = "fly1" CLASS = "fly"> <A HREF = "#" ...
^
Error: missing a required sub-element of "HEAD"

Line 100, column 38:
</DIV> <SCRIPT LANGUAGE = "JavaScript"> /* Simple version detection */
^
Error: required attribute "TYPE" not specified

kdjoergensen
04-11-2001, 10:56 AM
The script is only set up to handle Netscape 4 and Microsoft Internet Exploder..

To make it work in Netscape 6 you can do this:

At the very begining of your script statement
put following:

<SCRIPT LANGUAGE = "JavaScript1.2">
/* Show an object */
if (document.getElementById && (!document.all)){
document.all = document.getElementsByTagName("*");
}


Try it now...
rgds Kenneth

whkoh put your script through a validator, but one of the problems with these is that it can not validate NS vs IE,but only tell you if there are any coding mistakes (syntaxes). Suggest you make the type declarations, if you like,but right now it is not required by browsers (unless you use strict doc type delcaration in NS6 and IE6. If you do not know what it means, dont worry.. you don't have to use the type declarations, then).