Javascript include not working in Safari?

Discussion in 'Javascript' started by andrewljohnson, Jan 26, 2009.

  1. Hi everyone,

    If you visit this page in Safari, you will just see a paragraph of
    text: http://cabin.trailbehind.com/

    In Firefox, the search box and the side menu get rendered properly
    (via javascript).

    Here is a test I did. The first Alert fires, but not the second Alert.
    Anyone have any thoughts on this mystery?

    window.onDomReady(onReady);

    function onReady() {
    var menuWidget = renderHomeMenu();
    ...
    }

    //include via javascript include media/javascript/Widgets/
    MenuWidget.js
    function renderHomeMenu() {
    alert(1) //NEVER FIRES
    menuWidget = new MenuWidget('col2', false);
    }


    I also put an alert in the main body of MenuWidget.js, which should
    fire when the include happens, but it doesn't. Also, when I check the
    Safari console, it can't find function renderHomeMenu().

    What am I doing wrong?

    Thanks,
    Andrew
    andrewljohnson, Jan 26, 2009
    #1
    1. Advertising

  2. andrewljohnson

    RobG Guest

    On Jan 26, 12:35 pm, andrewljohnson <> wrote:
    > Hi everyone,
    >
    > If you visit this page in Safari, you will just see a paragraph of
    > text:http://cabin.trailbehind.com/
    >
    > In Firefox, the search box and the side menu get rendered properly
    > (via javascript).
    >
    > Here is a test I did. The first Alert fires, but not the second Alert.
    > Anyone have any thoughts on this mystery?
    >
    > window.onDomReady(onReady);
    >
    > function onReady() {
    >   var menuWidget = renderHomeMenu();
    >   ...
    >
    > }
    >
    > //include via javascript include media/javascript/Widgets/
    > MenuWidget.js
    > function renderHomeMenu() {
    >    alert(1) //NEVER FIRES
    >    menuWidget = new MenuWidget('col2', false);
    >
    > }
    >
    > I also put an alert in the main body of MenuWidget.js, which should
    > fire when the include happens, but it doesn't. Also, when I check the
    > Safari console, it can't find function renderHomeMenu().
    >
    > What am I doing wrong?


    What you failed to mention is that you are loading a total of 21
    script files plus have a couple of script elements. Create a small
    test that uses the *minimum* number of files (preferably one) and
    isolate the error. Then maybe it can be discussed.


    --
    Rob
    RobG, Jan 26, 2009
    #2
    1. Advertising

  3. andrewljohnson

    Jorge Guest

    On Jan 26, 3:35 am, andrewljohnson <> wrote:
    >
    > What am I doing wrong?
    >
    > Thanks,
    > Andrew


    That's what Safari is complaining about:

    •Unmatched </head> encountered. Ignoring tag. http://cabin.trailbehind.com/
    (line 700)

    •Extra <body> encountered. Migrating attributes back to the original
    <body> element and ignoring the tag.http://cabin.trailbehind.com/
    (line 702)

    •TypeError: Result of expression 'h[af]' [undefined] is not an object.

    --
    Jorge.
    Jorge, Jan 26, 2009
    #3
  4. andrewljohnson

    RobG Guest

    On Jan 26, 5:53 pm, Jorge <> wrote:
    > On Jan 26, 3:35 am, andrewljohnson <> wrote:
    >
    >
    >
    > > What am I doing wrong?

    >
    > > Thanks,
    > > Andrew

    >
    > That's what Safari is complaining about:
    >
    > •Unmatched </head> encountered.[...]
    > •Extra <body> encountered.[...]


    I think those are the result of invalid markup (for such as small
    page, it has seriously broken markup, I guess the OP thought you could
    use a DOCTYPE of XHTML 1.0 strict, then serve it as text/html and all
    would be well).

    > •TypeError: Result of expression 'h[af]' [undefined] is not an object.


    I don't get that far. I get a series of messages that script in the
    page is making Safari unresponsive, so eventually I told it to stop.
    Firefox has the same issue. Forcing a 1.2MB home page on visitors is
    unreasonable, many will not even finish loading it before heading off
    elsewhere.

    Some of the map pages are nearly 3MB, with over 800kB of script.


    --
    Rob
    RobG, Jan 26, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Bogenberger
    Replies:
    3
    Views:
    899
    Andreas Bogenberger
    Feb 22, 2008
  2. Foreman
    Replies:
    5
    Views:
    220
    Foreman
    Jan 25, 2005
  3. JB
    Replies:
    3
    Views:
    133
    Fred Oz
    Nov 7, 2004
  4. Replies:
    4
    Views:
    254
    Randy Webb
    Feb 18, 2006
  5. Replies:
    2
    Views:
    123
Loading...

Share This Page