Click to See Complete Forum and Search --> : JacaScript problem in DreamWeaver
Digital Dragon
01-03-2003, 06:58 PM
Remember when I had that JavaScript problem where I wanted to display random quotes?
Well..it works great in FrontPage but when I inserted the script in DreamWeavers HTML...I used the Java de-bugging and it highlighted the HTML tag of the javascipt stating it expected a "expression".
What is it supposed to mean and how would I correct that? :confused:
khalidali63
01-03-2003, 07:05 PM
Look at the code or post it here.
Its missing a qoute/equal sign or a bracket.
Khalid
Digital Dragon
01-03-2003, 07:12 PM
<html>
<head>
<body>
<script language="JavaScript">
QuoteArray = new Array(
"Life is like the game of chess, when it is all over the kings and pawns all go back in the same box",
"I felt like working but after I sat down and had some coffee the feeling soon dissappeared",
"I like swords",
"If you're gonna get mad every time I do something stupid then I guess I'll just have to stop doing stupid things!",
"MWAA-HAHAHAHAHAHAHAHAHAHAHA......",
"There is only one way out and it is being blocked by cannibalistic lawyers.",
"D'oh!",
"I've fallen and I can't get up.",
"Are you sick of these quotes yet?",
"Please, I wanna be a clone now.",
"..........",
"Ask my cat, he seen everything.",
"Do not iron your cothes while wearing them.",
"ACK!! The voices...THE VOICES!! OH GOD NOT AGAIN!!! Make them stop...oh please, MAKE THEM STOP!",
"Todays Tip: Do not drive your car with the sun shield in place.",
"Todays Tip: Don't eat lead!");
RandomNo = Math.floor(QuoteArray.length * Math.random());
document.write("<b>" + QuoteArray[RandomNo] + "</b>");
</script>
I forgot the </body> and </html> tags but Dreamweaver did not point that out....but the code is the same one I posted yesterday only with a few more quotes....
khalidali63
01-03-2003, 07:41 PM
Can't seem to find any apparent errors,
where does DreamWeaver breaks at in this code?
Digital Dragon
01-03-2003, 07:47 PM
It highlights the <html> tag at the beginning of the whole javascript thingee and says it expeced a "expression"....I put the code inside a table but that should not matter one bit as i did it in FrontPage with no problems.
It says expressions are things like variable names, numbers or string of literals.....kinda weird since I used DreamWeavers own tools to insert javascript.....
khalidali63
01-03-2003, 07:57 PM
the code you posted here is missing <title></title> tags,I am not sure how strict Dream Weaver is.
Are you sure there isn't some tag or element that Dream Weaver generates itslef and its looking for that element?
Charles
01-03-2003, 08:00 PM
It sounds like the debugger thinks that the HTML is part of a script. Either there is a bug in Dreamweaver, you are using it incorrectly or you are doing something else that you are not telling us.
By the way, The beginning and ending tags of the HTML, HEAD and BODY elements are all optional. You do need to declare the Document Type and content type and you need to use the TYPE attribute instead of the LANGUAGE attribute with the SCRIPT element. id est:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Quote Array</title>
<script type="text/javascript">
Digital Dragon
01-03-2003, 08:04 PM
I don't know but now I cannot get into the "view" mode of my page so I can see the html code....I may have to restrat the computer or something.
khalidali63
01-03-2003, 08:06 PM
As a matte of fact when I checked your document with strict DTD, I noticed that you are missing end tags for <head> as well.put them in tooas well as title tags
<html>
<head><title></title></head><body></body></html>
Digital Dragon
01-03-2003, 08:19 PM
So are you saying that at the beginning when I have <head> I am supposed to put </head> right underneath it??
Won't that indicate the end of the code??
Secondly the code worked in FrontPage when I used the language type for the javascipt it seemed to function..but then again DreamWeaver is different from FrontPage....however now I cannot view the html code of the page I had put the javascript in...even when I deleted the java dreamweaver won't let me go into "view" mode to adjust the html...so I gotta reconstruct my page again I guess...
Well....thanks for your help.
khalidali63
01-03-2003, 08:32 PM
what version of dream weaver u r using?
Digital Dragon
01-03-2003, 08:36 PM
I am using DreamWeaver 4 and I also am using FrontPage 2002.
Digital Dragon
01-03-2003, 09:47 PM
Well...nevermind about the code view problem in Dreamweaver..it seems that after I used the script de-bugger DreamWeaver collapsed the view window whenever I selected code view...
So all I had to do was pull down the window to see it...I feel like such a doofus! :rolleyes:
khalidali63
01-03-2003, 10:16 PM
Well I guess I can un install the DW4 now..:-)
Khalid
Digital Dragon
01-03-2003, 10:20 PM
Uh-huh....:rolleyes:
But I am still going to have to figure out the java...why should the script language be interpretted so differently from one web designing program to another though?
khalidali63
01-03-2003, 10:24 PM
First of all,if you use FrontPage htat means you are not following the actual W3C standards.And ofcourse on the same note,DWis probably the same.
To make web pages act in a particular way they both( I know MS does it)probably add custom tags and objects..so when you go around on the net you are forced to use MS products or else you can not get the desired functioanlity..
just a thought
Khalid
The following code works fine in Dreamweaver MX.
<html>
<head>
</head>
<body>
<script language="JavaScript">
QuoteArray = new Array(
"Life is like the game of chess, when it is all over the kings and pawns all go back in the same box",
"I felt like working but after I sat down and had some coffee the feeling soon dissappeared",
"I like swords",
"If you're gonna get mad every time I do something stupid then I guess I'll just have to stop doing stupid things!",
"MWAA-HAHAHAHAHAHAHAHAHAHAHA......",
"There is only one way out and it is being blocked by cannibalistic lawyers.",
"D'oh!",
"I've fallen and I can't get up.",
"Are you sick of these quotes yet?",
"Please, I wanna be a clone now.",
"..........",
"Ask my cat, he seen everything.",
"Do not iron your cothes while wearing them.",
"ACK!! The voices...THE VOICES!! OH GOD NOT AGAIN!!! Make them stop...oh please, MAKE THEM STOP!",
"Todays Tip: Do not drive your car with the sun shield in place.",
"Todays Tip: Don't eat lead!");
RandomNo = Math.floor(QuoteArray.length * Math.random());
document.write("<b>" + QuoteArray[RandomNo] + "</b>");
</script>
</body>
</html>
Digital Dragon
01-03-2003, 10:30 PM
So I wonder how I am supposed to do that then?
The only reason it worked is because I copied the functional part of the code from the HTML reference book..I only added my own quotes..so Dreamweaver apparently uses a different type of java language...so how am I supposed to know what tags and language it uses then?
Digital Dragon
01-03-2003, 10:31 PM
Well..I will try it one more time then.
I gotta go now...thank everyone for your help....