View Full Version : XHTML java script Error
trainguy77
Apr 8, 2004, 07:52 PM
This is the code for a template i am making
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>
youth
</title>
</head>
<body background="JPG/backgroundforwebpage.jpg">
<table width="876" border="1">
<tr><td width="126" background="JPG/leftbar.jpg">
<script type='text/javascript' src='menu_var.js'></script>
<script type='text/javascript' src='menu_com.js'></script>
<noscript>Your browser does not appear to support JavaScript!</noscript>
</td>
<td width="750" background="JPG/main.jpg">
<table border="1" width="100%" height="100%">
<tr>
<td width="560" valign="top">hi</td>
<td width="190" valign="top">hi</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
When i remove the doctype and change it to something other than XHTML the menu apears why is this? I already know about the height thing and background elements but i need to do this for the way i want the page to look.
mnkeybsness
Apr 8, 2004, 08:47 PM
try and be more specific... cause i'm a little confused, but my best guess is that menu_var.js is not loading when the file is specified as XHTML... perhaps it would help if you posted the javascript file... and you can use the "[code]" command in your post a / in before the word code for the closing tag.
Westside guy
Apr 8, 2004, 10:42 PM
Yes, I agree with mnkeybsness - more info would be helpful. For example, do you see the same problem in all varieties of browsers, or just one? Also, seeing all the code would be nice - specifically the code for the scripts. Right now it could be any number of things; maybe even something simple like a table tag not being closed.
Why not give us the URL of the "broken" page?
trainguy77
Apr 10, 2004, 04:33 PM
this same code will work fine if i remove the XTHML doctype line. So i do not think it is the code for the menu. This code is not written by me. The code can be found at: menu (http://www.southcalgary.org/youth/standard/menu/) When you go here you will see three files related to the menu: menu_var.js (The variables) menu_com.js (backbone) javascript.js( more backbone) This is a very picky code i have only ever changed menu_var.js the rest i do not understand. But since it works fine in a non XHTML document with no errors i do not see why it would not run in XHTML. It acts as if it runs. at the bottom of the page it says it is building and then it says it is ready for use. I do not have a URL of a broken page becasue it is not online. Only the working non XHTML page is online
Rower_CPU
Apr 11, 2004, 01:40 AM
Single quotes are valid in JS, but not (X)HTML. Try double quotes for the <script> attributes.
<script type="text/javascript" src="menu_var.js"></script>
<script type="text/javascript" src="menu_com.js"></script>
XHTML is pickier than HTML about quoting attributes, which is probably why it "breaks" when you add the XHTML doctype. In the future, try running your code through the W3C validator (http://validator.w3.org/) - it will tell you exactly where your errors are.
trainguy77
Apr 11, 2004, 02:29 PM
i tryed this two days ago not change. I also ran the same code with the validator and it only complained about the background within the table.
Rower_CPU
Apr 11, 2004, 02:44 PM
OK, well at this point, it's tough to troubleshoot further without seeing a live example.
trainguy77
Apr 11, 2004, 06:21 PM
version:Here is a working version (http://www.southcalgary.org/youth/XHTML/test2.html) And a non working version (http://southcalgary.org/youth/XHTML/test.html) The second has the doctype line and the first does not. a added the " " instead of ' ' no difference.
mnkeybsness
Apr 11, 2004, 10:34 PM
ew ew ew ew ew ew
here's some pointers...
get rid of the background-image. it's fugly.
that menu can be done a lot easier with CSS.
learn CSS
learn some more CSS
don't use tables
learn CSS
trainguy77
Apr 11, 2004, 11:27 PM
i found way newer versions of the menu. I did not know that you can do some thing like tables with CSS. I know some CSS, but not as much as i should(i guess!)
Thanks i will read up on some CSS
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.