"Error: mozilla is not defined"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter

    "Error: mozilla is not defined"

    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(brows er,contentPage) {
    //contentPage is the page to load in the iframe

    var header = "<html><head><t itle>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=\"styleshee t\" type=\"text/css\"
    href=\"system/" + "/" + browser + "/" + "styles.css\">" ;
    header += "</head><body>";

    var body = "<table class=\"contain er\"><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=\"navigat ion\" id=\"links\"><a href=\"#\"
    onClick=\"build Page(" + 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.appNa me;

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

    buildPage(brows er,"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.j s"></script>
    </head>
    <body>
    <script>buildLi st("mozilla","a rticle");</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
  • Spamless

    #2
    Re: &quot;Error: mozilla is not defined&quot;

    In article <5ebd9070.03072 42301.5bc70244@ posting.google. com>, Peter wrote:[color=blue]
    >
    > // 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=\"navigat ion\" id=\"links\"><a href=\"#\"
    > onClick=\"build Page(" + browser + "," + "'default'" + "," +
    > "'system/pages/library.html'); \">Library</a></div>";[/color]

    Ther replaces browser with its value, the string, mozilla, creating
    browser(mozilla ,....) instead of browser("mozill a",...)[color=blue]
    >
    > 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.[/color]

    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="mozill a" and then do alert(browser),
    it shows the string value, mozilla, not "mozilla"). Add the
    double quotes the the new page it is writing.

    Comment

    • Peter

      #3
      Re: &quot;Error: mozilla is not defined&quot;

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

      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

      Comment

      Working...