By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,034 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,034 IT Pros & Developers. It's quick & easy.

"Error: mozilla is not defined"

P: n/a
Hello,

First of all, sorry for all the code. I don't know how to explain my
problem without it.

I have a javascript function which can build a webpage dynamically. A
striped down version of the function
looks like this:

BEGIN CODE

function buildPage(browser,contentPage) {
//contentPage is the page to load in the iframe

var header = "<html><head><title>SomeTitle</title>";

// different browsers will get different .css-files. the argument
// "browser" is used to select which
// .css-file to use (mozilla, opera or IE)
header += "<link rel=\"stylesheet\" type=\"text/css\"
href=\"system/" + "/" + browser + "/" + "styles.css\">";
header += "</head><body>";

var body = "<table class=\"container\"><tr><td>";

// here comes the line which generates an error.
// The pages which is build with the buildPage function
// contains a call to the buildPage function which is executed
// in the case a user clicks the link "Library".
// This is to build the page again, but with a different page
// loaded in the iframe (se below)
body += "<div class=\"navigation\" id=\"links\"><a href=\"#\"
onClick=\"buildPage(" + browser + "," + "'default'" + "," +
"'system/pages/library.html');\">Library</a></div>";
// here's the iframe which uses the contentPage argument
body += "<iframe class=\"content\" src=\"" + contentPage +
"\"></iframe>";
body += "</td></tr></table>";

var footer = "</body></html>";

var page = header + body + footer;

document.write(page);
}

END CODE

The HTML-page which calls this one looks like this:

BEGIN CODE

<html>
<head>
<title></title>
<script src="system/js/buildPage.js"></script>
</head>
<body>
<script>
var browser = navigator.appName;

if (browser == "Opera") {
browser = "opera";
} else if (browser == "Microsoft Internet Explorer") { browser = "explorer";
} else browser = "mozilla";

buildPage(browser,"system/pages/frontpage.html");
</script>
</body>
</html>

END CODE

And the page library.html looks like this:

BEGIN CODE

<html>
<head>
<script src="../../system/db/library.js"></script>
<script src="../../system/js/build.js"></script>
<script src="../../system/js/showHideLayer.js"></script>
</head>
<body>
<script>buildList("mozilla","article");</script>
</body>
</html>

END CODE

My problem is that when I press the link "Library" I get this error
from mozillas javascript console:

"Error: mozilla is not defined"

It does find out that the argument "browser" is mozilla (when using
this browser). Now all it has to do is use this string to collect the
correct .css-file.

What exectly is meant with the above error and how do I make the
browser used the string "mozilla" which it found from the "browser"
argument?

Thanks
/Peter
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <5e**************************@posting.google.com >, Peter wrote:

// here comes the line which generates an error.
// The pages which is build with the buildPage function
// contains a call to the buildPage function which is executed
// in the case a user clicks the link "Library".
// This is to build the page again, but with a different page
// loaded in the iframe (se below)
body += "<div class=\"navigation\" id=\"links\"><a href=\"#\"
onClick=\"buildPage(" + browser + "," + "'default'" + "," +
"'system/pages/library.html');\">Library</a></div>";
Ther replaces browser with its value, the string, mozilla, creating
browser(mozilla,....) instead of browser("mozilla",...)
My problem is that when I press the link "Library" I get this error
from mozillas javascript console:

"Error: mozilla is not defined"

It does find out that the argument "browser" is mozilla (when using
this browser). Now all it has to do is use this string to collect the
correct .css-file.


The problem is that when you wrote the code to the new page,
you wrote the string value of the variable browser, the string
mozilla (if you set browser="mozilla" and then do alert(browser),
it shows the string value, mozilla, not "mozilla"). Add the
double quotes the the new page it is writing.
Jul 20 '05 #2

P: n/a
> The problem is that when you wrote the code to the new page,
you wrote the string value of the variable browser, the string
mozilla (if you set browser="mozilla" and then do alert(browser),
it shows the string value, mozilla, not "mozilla"). Add the
double quotes the the new page it is writing.


That seems to be it. It works fine in Opera 7.03 and IE 6 on Win XP,
but Mozilla 1.4 appears to be loading the new page, but then ends up
loading the old page again.

Also in Opera and IE, after having clicked the link, no other links
work anymore. IE gives the error "an object was expected" (This is a
translation. I don't know the exact words used in the english IE).

Any suggestions as to what is wrong?

Thanks
/Peter
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.