P
Peter
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
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