PDA

View Full Version : doucment.write problem


shoofy
10-28-2003, 09:07 PM
I have a site on geocities and I got very annoyed by all of their annoying ads. What I did was have the page load from a javascript file, basically just putting document.writeln(""); around every line. The problem is that I want to add the following slideshow code to the site:<script language="JavaScript1.2">


var variableslide=new Array()

//variableslide[x]=["path to image", "OPTIONAL link for image", "OPTIONAL text description (supports HTML tags)"]

variableslide[0]=['ball.gif', '', '']
variableslide[1]=['spaceship.gif', 'http://www.space.com', 'Has aliens landed on earth? You decide.']
variableslide[2]=['cake.gif', '', '']

//configure the below 3 variables to set the dimension/background color of the slideshow

var slidewidth='130px' //set to width of LARGEST image in your slideshow
var slideheight='120px' //set to height of LARGEST iamge in your slideshow, plus any text description
var slidebgcolor='#F3F3F3'

//configure the below variable to determine the delay between image rotations (in miliseconds)
var slidedelay=3000

////Do not edit pass this line////////////////

var ie=document.all
var dom=document.getElementById

for (i=0;i<variableslide.length;i++){
var cacheimage=new Image()
cacheimage.src=variableslide[i][0]
}

var currentslide=0

function rotateimages(){
contentcontainer='<center>'
if (variableslide[currentslide][1]!="")
contentcontainer+='<a href="'+variableslide[currentslide][1]+'">'
contentcontainer+='<img src="'+variableslide[currentslide][0]+'" border="0" vspace="3">'
if (variableslide[currentslide][1]!="")
contentcontainer+='</a>'
contentcontainer+='</center>'
if (variableslide[currentslide][2]!="")
contentcontainer+=variableslide[currentslide][2]

if (document.layers){
crossrotateobj.document.write(contentcontainer)
crossrotateobj.document.close()
}
else if (ie||dom)
crossrotateobj.innerHTML=contentcontainer
if (currentslide==variableslide.length-1) currentslide=0
else currentslide++
setTimeout("rotateimages()",slidedelay)
}

if (ie||dom)
document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>')

function start_slider(){
crossrotateobj=dom? document.getElementById("slidedom") : ie? document.all.slidedom : document.slidensmain.document.slidenssub
if (document.layers)
document.slidensmain.visibility="show"
rotateimages()
}

if (ie||dom)
start_slider()
else if (document.layers)
window.onload=start_slider

</script>

<ilayer id="slidensmain" width=&{slidewidth}; height=&{slideheight}; bgColor=&{slidebgcolor}; visibility=hide><layer id="slidenssub" width=&{slidewidth}; left=0 top=0></layer></ilayer>

As you can see, it contains the line: "document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>')" and because this uses both single quotes and double quotes, I don't know how to include this inside another document.writeln("");. Any ideas?

kevin
10-28-2003, 09:10 PM
"document.write('<div id=\"slidedom\" style=\"width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'\"></div>')"

shoofy
10-28-2003, 09:49 PM
That made that line load correctly, but now can you tell me why the script itself isn't working? The slideshow doesn't show up at all and I get a syntax error on line 136 char 1.

n8thegreat
10-28-2003, 09:50 PM
you dont need to escape double quotes when you start it with a single quote

what exactly is it doing (or not doing)? what errors does it generate?

*edit* which line in the script is line 136?

kevin
10-28-2003, 09:56 PM
Originally posted by shoofy
That made that line load correctly, but now can you tell me why the script itself isn't working? The slideshow doesn't show up at all and I get a syntax error on line 136 char 1.

Sorry, I don't trouble-shoot javascripts.

shoofy
10-28-2003, 09:58 PM
Does the line number start from the beginning of the script or the page itself?

shoofy
10-28-2003, 10:00 PM
There were actually more errors that I didn't notice:
Line 45 char 52 Expected ";"
Line 99 char 29 Expected ";"
Line 135 char 1 Syntax error

n8thegreat
10-28-2003, 10:06 PM
if it is in an html page, its from the beginning of the html document, if its in a .js file its form the beginning of the js file

Willy Duitt
10-28-2003, 10:59 PM
I have a site on geocities and I got very annoyed by all
of their annoying ads. What I did was have the page load
from a javascript file, basically just putting
document.writeln(""); around every line. The problem is
that I want to add the following slideshow code to the
site:

I do not condone disabling the banner ads on free hosts.
If you don't want to deal with banner ads. Get a paid host.

Please be further advised that if Geocites finds you
disabling their banner ads, your site will be TOS'ed!!

That being said. Here's a hint.
Their ads are triggered by the <body> tag.
You can either document.write the <body> tag
or encrypt it and/or the page codes with this (http://www.transload.net/~cyberrite/Tools/Convert/Encryptor.html) utiltiy.


.....Willy

shoofy
10-30-2003, 10:50 PM
I wouldn't have a problem if it were just a banner ad, I could live with that, but this thing covers the content of the site and is annoying to close. Personally, I agree that the site should move to its own domain, but I, who am just the web designer, get no say in the matter. I guess it is understandable because the site makes no profit in any form as much as the guy in charge would like to believe it does.