473,569 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Solving the infamous document.layers no properties error?

I'm not a javascript guy, but the use of this banner rotator script
has given me fits. I know a few causes of the problem thus far, one
being the layer tags aren't supported under Netscape 7.1 just the
entire 4.X series. Script works fine under IE. I've tried a few
things to get it working under Netscape, such as defining a style for
the bannerLayer with the style tag, and trying to define the style
under the div tag, I've tried the getElementById but that doesn't work
either or else I'm doing it wrong.

It errors out here with that document.layers has no properties error:
var layer = (document.all)? document.all.ba nnerLayer :
document.layers .bannerL
ayer.document.l ayers[0];

http://mudlist.betterbox.net/testing.html

<script language="JavaS cript">
<!--
/*************** *************** *************** *************** *************/
/* SCRIPT SETTINGS
*/
/*************** *************** *************** *************** *************/

//Wheteher the banner displayed randomly
var RANDOM_BANNER = true;

//update in seconds
var UPDATE_FREQUENC Y = 150;

//banner height in pixels
var imgH = "70";

//banner width in pixels
var imgW = "468";

//Links target
var target = "_top";

//Initialize the array of links
var arrLinks = new Array();
arrLinks[0] = "http://promisedland.be tterbox.net/";
arrLinks[1] = "http://phoenix.betterb ox.net";
arrLinks[2] = "http://lotn.betterbox. net";
arrLinks[3] = "http://kivekia.betterb ox.net";
arrLinks[4] = "http://patterns.better box.net";

//Initialize array of images
var arrImages = new Array();
arrImages[0] = "http://promisedland.be tterbox.net/pl.gif";
arrImages[1] = "http://phoenix.betterb ox.net/images/banner.gif";
arrImages[2] = "http://lotn.betterbox. net/cgi-bin/banner.cgi";
arrImages[3] = "http://kivekia.betterb ox.net/images/kdbanner.jpg";
arrImages[4] = "/images/pebanner.gif";

//Any comments attached to the displaye image
var arrComments = new Array();
arrComments[0] = "Promised Land MUD";
arrComments[1] = "Phoenix MUD";
arrComments[2] = "Legend of the Nobles";
arrComments[3] = "Kivekian Dawn";
arrComments[4] = "Patterns End";

/*************** ********* DO NOT EDIT BELOW THIS LINE
*************** *********/
var updateBanner;
var COUNTER = 0;
var last = 0;

function buildBanner()
{
var randomNum;
if(RANDOM_BANNE R)
{
randomNum = Math.floor(Math .random() * arrLinks.length );
while(randomNum == last)
randomNum = Math.floor(Math .random() * arrLinks.length );
last = randomNum;
}

var layer = (document.all)? document.all.ba nnerLayer :
document.layers .bannerL
ayer.document.l ayers[0];

COUNTER = (RANDOM_BANNER) ? randomNum : COUNTER;

var aLink = (arrLinks[COUNTER])? arrLinks[COUNTER] : "#";
var anImage = (arrImages[COUNTER])? arrImages[COUNTER] : "";
var aComment = (arrComments[COUNTER])? arrComments[COUNTER] : "";
var aTarget = (target)? target : "_top";

var bannertext;

if ( anImage.indexOf ("cgi") != -1 ) {
bannertext = "<iframe name=\"frame\" src=\"" + anImage + "\"
width=" + img
W;
bannertext += " height=" + imgH + " frameborder=0
scrolling=\"no\ "></i
frame>";
}
else {
bannertext = "<a href=\"" + aLink + "\" target=\"" +
aTarget + "\">";
bannertext += "<img src=\"" + anImage + "\" border=0 alt=\"" +
aComment +
"\">";
bannertext += "</a>";
}
if(document.all )
layer.innerHTML = bannertext;
else
{
layer.resizeTo( imgW,imgH);
var doc = layer.document;
doc.open();
doc.write(banne rtext);
doc.close();
}
}
//-->

</script>
</head>

<!-- BANNER STARTS -->

<table border=0 cellspacing=0 cellpadding=0 align=center>
<tr><td>
<div id="bannerLayer ">
<layer name="bannerLay er" visibility="sho w" width=&{imgW};
height=&{imgH}; >
</layer>
</div>
</td></tr></table>
<!-- BANNER ENDS -->

<!-- KEEP THIS SCRIPT AT THE VERY BOTTOM OF THE PAGE -->
<script>
<!--
function banner()
{
buildBanner();
COUNTER++;
COUNTER = (COUNTER == arrLinks.length )? 0 : COUNTER;
}
updateBanner = setInterval("ba nner()", (UPDATE_FREQUEN CY * 1000));
//-->
</script>
Jul 23 '05 #1
3 3314
In article <52************ **************@ posting.google. com>,
cr**********@ty po.net enlightened us with...

It errors out here with that document.layers has no properties error:
var layer = (document.all)? document.all.ba nnerLayer :
document.layers .bannerL
ayer.document.l ayers[0];


Watch for word wrap...
Not tested; works in theory.

var layer = document.getEle mentById?docume nt.getElementBy Id
("bannerLayer") :document.all?d ocument.all
["bannerLaye r"]:document.layer s?document.laye rs["bannerLaye r"]:null;

if (layer == null)
{
alert("your browser can't run this script");
return;
}

--
--
~kaeli~
The more ridiculous a belief system, the higher probability
of its success.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
"kaeli" <ti******@NOSPA M.comcast.net> wrote in message
news:MP******** *************** *@nntp.lucent.c om...
In article <52************ **************@ posting.google. com>,
cr**********@ty po.net enlightened us with...

It errors out here with that document.layers has no properties error:
var layer = (document.all)? document.all.ba nnerLayer :
document.layers .bannerL
ayer.document.l ayers[0];


Watch for word wrap...
Not tested; works in theory.

var layer = document.getEle mentById?docume nt.getElementBy Id
("bannerLayer") :document.all?d ocument.all
["bannerLaye r"]:document.layer s?document.laye rs["bannerLaye r"]:null;

if (layer == null)
{
alert("your browser can't run this script");
return;
}


Yes that fixed that problem, then it fires off more errors with this part:

layer.resizeTo( imgW,imgH);
var doc = layer.document;
doc.open();
doc.write(banne rtext);
doc.close();

doc has the same no properties error, and calls resizeTo not a
function...bleh .
Jul 23 '05 #3
In article <LL************ ******@newssvr1 6.news.prodigy. com>,
cr**********@de adspam.com enlightened us with...

Yes that fixed that problem, then it fires off more errors with this part:

layer.resizeTo( imgW,imgH);
var doc = layer.document;
doc.open();
doc.write(banne rtext);
doc.close();

doc has the same no properties error, and calls resizeTo not a
function...bleh .


change this block to

if(layer.innerH TML) // was if (document.all)
layer.innerHTML = bannertext;
else if (document.layer s)
{
layer.resizeTo( imgW,imgH);
var doc = layer.document;
doc.open();
doc.write(banne rtext);
doc.close();
}
else
{
// whatever you want to do for non-compliant browsers
}

--
--
~kaeli~
The Bermuda Triangle got tired of warm weather. It moved to
Finland. Now Santa Claus is missing.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4491
by: 2obvious | last post by:
This is a pipe dream, I realize, but I'm trying to emulate the functionality of the W3C DOM-supported document.getElementsByTagName method under the very nightmarish Netscape 4. Through some sleuthing, I was able to find what serves as a document.getElementById emulator at http://www.xs4all.nl/~ppk/js/dhtmloptions.html#versionb. (Below...
6
6828
by: David List | last post by:
I'm having a problem using different properties of the document object in the example javascripts in my textbook with browsers that identify themselves as using the Mozilla engine. One example of these problems is using document.layers. I have Google'd for examples of how to use the document object specifically with Mozilla, but I cannot find...
3
9820
by: Catherine Lynn Smith | last post by:
I am creating a webpage with dhtml <DIV> layers and I want a link on one layer to modify the content on another but I seem to keep running into errors. Basically I create a layer in the middle of the screen that initially comes up with a gif image of a house: <!-- start "house" layer definition for center of screen --> <DIV id="house"...
12
10140
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical scrollbar, you get the height of the entire document, screwing up any chance of centering a window in the browser using these values. Is there a...
10
54857
by: InvisibleMan | last post by:
Hi, Thanks for any help in advance... Okay, I have the JS listed below that calls for the display of the (DIV) tag... cookie function not included, as don't feel its necessary but you'll get the idea! function closeall() { var objs;
5
3361
by: John | last post by:
Hi, I have the following code: <FORM> <font size="3">Brands </font><br /> <SELECT SIZE="1" NAME="categorylist" STYLE="font-size: 8pt"> <OPTION VALUE=http://my.domain,.com/cetegory1.html selected>Category 1</OPTION> <OPTION VALUE=http://my.domain,.com/cetegory2.html>Category
4
3787
by: ashkaan57 | last post by:
Hi, I am using the following code to show/hide part of an html page. It works in Netscape and Firefox but dies in IE: "Error: document.layers is null or not an object" <style> ..noshow { display: none; } ..menu {
7
2377
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many forms containing questions. As the user answers one of the questions, that form is hidden and the next is displayed. Also, as the user answers each question a "count" variable is updated based on...
2
2885
by: chrisg | last post by:
Hi I have a problem with the following javascript in firefox (works fine in IE). I've done some reading and found that i need to pass in the element ID, but i cant figure out how to do it. Here's the code. Hope someone can help: function get_Style_Obj(objID) { var StyleObj;
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.