Results 1 to 5 of 5

Thread: How to turn a menu into a javascript file?

  1. #1
    Join Date
    Jul 2007
    Location
    New Zealand
    Posts
    81
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default How to turn a menu into a javascript file?

    i've deleted my original post as I found a handy wee javascript generator that is particularly good for mugs like me that are ignorant to javascript.

    Anyway, the only problem with the script I have in my .js file is that now on the page I have the script working (a navigation menu) - I have document.write(' leaked on the page.

    How can I get rid of this?
    Last edited by Eternal_Howl; 07-22-2007 at 08:30 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    document.write('
    Is the beginning of a javascript statement that tells the browser to write some (usually HTML) code to the page as it is loading, as if it were already hard coded into the page. If you are seeing part of one of those statements when you view the page in the browser, it means that part of one of those statements is in the wrong spot in your source code.

    To be more specific, we would need a link to your page.

    BTW, any menu that is made by javascript will not be available to folks who are using a browser without javascript or with javascript off.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2007
    Location
    New Zealand
    Posts
    81
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default

    Hi Jscheuer1.

    Thanks for replying.

    The page that the result (or javascript output) is on is http://chaosdesigns.110mb.com/newtest2.html. You'll see just above the menu the code leakage. It's nice to know it works, but it's obviously not formatted correctly.

    Normally, I would see document.write near the start of a javascript. This one appears to be near the end.
    Let me know if you want me to paste the code, but you can always find the link in the source anyway. Please excuse the layout, it's a work in progress - along with all the required kudos to the original menu script writer that I got the script off.

    Oh yes, and I am aware some people may not have javascript enabled and I will acknowledge that as soon as I get this sorted I'm running on crusty old 98SE, so I know too well that often webmasters often don't cater for any but themselves.

    Thanks.
    Last edited by Eternal_Howl; 07-23-2007 at 07:10 AM.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    From vmenu.js - remove the red part:

    Code:
    inc_vmenu_js =
    '<!-- Created with <STRONG><VMENU> -->\n<!-- http://www.s'
    + 'tronghtml.com/ -->\ndocument.write(\'<div id="cssvmenu"><'
    + 'ul><li><a href="http://chaosdesigns.110mb.com/index.html'
    + '" title=""><img src="/home.jpg" border="0"></a></li>\n<li class="men . . .
    Also, it would be good form and prevent any confusion over the scope of the inc_vmenu_js variable to declare it formally like so (this time add the red part):

    Code:
    var inc_vmenu_js =
    '<!-- Created with <STRONG><VMENU> -->\n<!-- http://www.s'
    + 'tronghtml.com/ -->\n<div id="cssvmenu"><'
    + 'ul><li><a href="http://chaosdesigns.110mb.com/index.html'
    + '" title=""><img src="/home.jpg" border="0"></a></li>\n<li class="men . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2007
    Location
    New Zealand
    Posts
    81
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default

    That was all? Awesome. Thank you! It's all good now. That was the first time I'd put a code in a .js file without it already being done for me (which actually seems fairly easy now - we shall see. I know javascript is touchy.).

    I did see the bit at the top where the author's title was but thought - don't mess with it and wasn't sure how it would affect the author's code - but I guess they're just statements so that if anyone downloads the code, they may find where it came from. Thank you so much. I know the more I mess with javascript, the more I'll learn.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •