36 users online (2 members and 34 guests)  


  Results 1 to 6 of 6

Related

  1. document.getElementById    Forum: Javascript Forum
    Replies: 0
  2. Replies: 0
  3. document.write() query    Forum: Javascript Forum
    Replies: 4
  4. Replies: 7
  5. Javascript document.write problems    Forum: Javascript Forum
    Replies: 3
  1. #1
    Android's Avatar

    Status
    Offline
    Join Date
    Oct 2002
    Location
    I AM CANADIAN
    Posts
    440

    Talking dicument.write question......

    Right now I'm working on a project that I may put on an intranet server for departmental use.
    What I have is a main menu:

    <div class="menu">
    <script type="text/javascript" src="menu.js">
    </script>
    </div>

    and an external javascript document called menu.js that I can edit the menu from. This menu works OK.

    My problem is with a different menu that will appear on several (but not all) of the pages which I would like to be able to edit from a different javascript document (exactly like I can on the first menu).
    I've set up the markup the same:

    <div class="content">
    <div class="sub">
    <script type="text/javascript" src="submenu.js">
    </script>
    </div>
    CONTENT information and STUFF HERE UNIQUE TO EACH PAGE
    </div>

    and in submenu.js I can put in the links for the menu and it works fine for the first seven links, but adding an eighth I get the script error:expected ')'error. I might eventually need two or three lines of links (hence the desire to edit in one place).
    Each links markup is like:
    <a href="whatever.html" onclick="window.open(this.href);return false;">Website</a>


    It's probably something pretty basic (about javascript) that I'm missing.
    I'm still searching for the answer, but if anybody has any input, it would be appreciated.

  2. #2
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    probably would need to see the submenu.js

    Dave

  3. #3
    Android's Avatar

    Status
    Offline
    Join Date
    Oct 2002
    Location
    I AM CANADIAN
    Posts
    440

    Talking Yeeeee Hawwwwww

    Figured it out all by myself.....

    Did you know that an apostrophe and a slash can't be used in the text of an anchor? Like:
    <a href="whatever.html">Some O/S's</a>
    I didn't That's why it thought it didn't get the expected ')' ....it thought I had closed the string. Cool....
    Now my question is:
    How to include apostrophies and slashes in a menu, and is there a master list (like HTML escapes) for javascript?
    Again, probably something simple that I can't find right now......
    Or, is this a case of live and learn for me....

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    You can escape ' in js like this -

    Code:
    \'
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    Android's Avatar

    Status
    Offline
    Join Date
    Oct 2002
    Location
    I AM CANADIAN
    Posts
    440

    Talking

    LOL I thought I had read something like that somewhere a long time ago, so I tried it first thing this morning. BINGO. Sometimes I scare myself........
    For the sake of the thread, I'll provide a couple of examples:
    Code:
    <a href="operating systems.html">O/S's</a>
    <a href="utilities.html">M/GRCV's</a>
    When called by a javascript document.write statement, the statement should look like:
    Code:
    [b]document.write('<a href="operating systems.html">O\/S\'s</a><a href="utilities.html">M\/GRCV\'s</a>')
    Correctomundo?
    Is there a list of characters somewhere where this applies? Or is it safe to assume that it applies to anything that isn't alpha-numeric?

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Anything that could be construed as JavaScript (eg ') or HTML (eg /)
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread