add a CSS menu toolbar (with links)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #16
    just have a look at your first line ... that is invalid according to the examples i showed you:

    [code=javascript]var menu = "<b><a style="color:#C 11B17">Introduc tion</a></b>"[/code]
    the second double-quote terminates the string-literal and a js-error will be raised since everything afterwards couldn't be evaluated correctly. so the following would be correct:

    Code:
    var menu = '<b><a style="color:#C11B17">Introduction</a></b>'
    or even:

    [CODE=javascript]var menu = "<b><a style=\"color:# C11B17\">Introd uction</a></b>"[/CODE]
    would be correct ... unless that is fixed it will not work.

    kind regards

    Comment

    • beacon
      Contributor
      • Aug 2007
      • 579

      #17
      I had taken into consideration the string business when I initially wrote the code, but apparently I'm not quite as knowledgeable as I need to be in some respects.

      I'm sorry for being a pain, but I'm confused about a certain section of the string I'm trying to create.

      I understand this part:
      [code=javascript]
      var menu = '<b><a style="color:#C 11B17">Introduc tion</a></b>'
      [/code]

      There's a string from where the bold tag begins until the bold tag ends. And there's a string embedded in that string to identify the color. It uses the alternate set of quotations to indicate that it isn't terminating the outside string. That part I'm clear on.

      Here's where I get lost:
      [code=javascript]
      var menu = '<b><a style="color:#C 11B17">Introduc tion</a></b>' +
      '<br />' +

      '<a class="left" target="_top" style="text-decoration:none "
      href="file:\\ds hsntwfd01\publi c\Computer Help Center\HTML Docs\CHC-Introduction\Qu ickStart.htm"
      onmouseover=\"t his.style.textD ecoration=\"und erline\";
      this.style.font Weight=\"bold\" ;
      window.status=\ "QuickStart\";r eturn true\"
      onmouseout=\"th is.style.textDe coration=\"none \";
      this.style.font Weight=\" \";
      window.status=\ " \"\">QuickSt art
      </a>' + '<br />'
      [/code]

      In this snippet, the first part of the string is the same as above. Then I concatenate the string to another string...the '</br>' part. Then I concatenate that to another string that initalizes the class, establish a reference link, sets up some formatting, and defines the onmouseover and onmouseout event procedures.

      After the class is initialized, that's where I begin to have trouble because I have 15 other blocks of code that are exactly the same as this except the link and the name change, respectively.

      The <a> tag and the </a> are both enclosed with single quotes to indicate the outer string. Inside, the href is enclosed with double quotes and closed before another string is opened. I think I've done that right without jeopardizing whether or not I terminated the string.

      After this point though, where the onmouseover begins, there are several instances where I have a string within a string, or I have multiple strings within strings. Has what I posted above come anywhere close setting this up properly?

      I tried googling javascript string literals to find examples where there were multiple html tags embedded in one javascript string, but I came up empty.

      Comment

      Working...