Michael Winter wrote:
On Tue, 07 Sep 2004 22:18:16 +0200, Johan <jo*********@ilseDOT.nl> wrote:
I've been working on the following piece of code and it works fine in
IE and Opera, dut keep getting the same error in Firefox. Can anyone
tell me what's wrong with this code? What I'm trying to do is rewrite
the left (navigationframe) and load a page on the right (mainframe).
[snipped code]
Could you provide a URL? I don't see anything wrong (though I might
have missed something). A working example would make it much easier to
see the problem.
I would like to mention a few points before I finish:
- You should make sure you escape "</" sequences into "<\/". This is
because browsers are allowed to treat "</" as the end of the SCRIPT
element.
- The TITLE element is required in a HTML document. Even if you leave
it empty[1],
<title></title>
always include it.
- You can use the writeln method to end a written line with a new-line
character.
- The language attribute in a SCRIPT element has been deprecated in
favour of the (required) type attribute. You needn't use the former any
more.
- As the content you're writing into the frame is static, why not load
a HTML file instead?
Mike
[1] There's no real reason to leave it empty. You'll always have some
form of label for a page.
Thanks for your reply. I changed the </ into <\/ and removed the
language bit, added a title and changed write into writeln and removed
the \n bits. This didn't solve it :(
I'm not using different html files because I would be changing to many
filis if I add or remove an menuitem. This way I'm only working on one
file. I will be changing the code into something more OO but for now
it's ok if it just would work.
I don't have a link to the code btw, sorry. The rest of the code is
build the same as the first part (as the setHome part). It is used to
show or hide several menuitems. There're no other functions in the file
(it is an .js file)
Here's the changed code, maybe it becomes more clear whats wrong(?):
function setPage(url) {
parent.mainframe.location.href = url.toString();
}
function setHome(pageCode) {
with (document) {
open();
writeln('<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
writeln('<html xmlns="http://www.w3.org/1999/xhtml">');
writeln('<head><link rel="stylesheet" type="text/css"
href="./nav.css" /><title>Belois Automatisering -
Software<\/title><script src="./nav.js"
type="text/javascript"><\/script><\/head>');
writeln('<body>');
writeln('<div id="navigation">');
writeln('<table>');
writeln('<tr><td><a href="#" onclick="setHome(\'./homemain.html\')"
class="current">Home<\/a><\/td><\/tr>');
writeln('<tr><td><a href="#"
onclick="setSoftware(\'./software.html\')">Software<\/a><\/td><\/tr>');
writeln('<tr><td><a href="#"
onclick="setLinks(\'linksmain.html\')">Links<\/a><\/td><\/tr>');
writeln('<tr><td><a href="#"
onclick="setInfo(\'./informatie.html\')">Informatie<\/a><\/td><\/tr>');
writeln('<\/table>');
writeln('<\/div>');
writeln('<\/body>');
writeln('<\/html>');
close();
setPage(pageCode);
}
}
....