displaying a string that contains ' (quote)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gomzi
    Contributor
    • Mar 2007
    • 304

    displaying a string that contains ' (quote)

    hi,

    I have a string like this -> what a great 'score'

    now when i try to display this in a div through javascript,

    iddiv.innerText = str;

    then i get an error that ')' is expected...

    my only guess is that it encounters the first quote and considers that the end of the string,

    so i would like to know as to how i could display the string correctly.

    thanks,
    gomzi.
  • DutchKingCobra
    New Member
    • Mar 2007
    • 37

    #2
    hi pal

    first dont use innerText as firefox does not use it
    as for your question
    Code:
    str='what a great \"score';
    
    iddiv=document.getElementById('mydiv')
    
    iddiv.innerHTML=str;
    well HTH
    peace

    Comment

    • gomzi
      Contributor
      • Mar 2007
      • 304

      #3
      Originally posted by DutchKingCobra
      hi pal

      first dont use innerText as firefox does not use it
      as for your question
      Code:
      str='what a great \"score';
      
      iddiv=document.getElementById('mydiv')
      
      iddiv.innerHTML=str;
      well HTH
      peace
      thanks mate..ya.sure.. will use innerHTML from now on. was wondering as to why firefox wasnt displaying it.so thanks for that tip.

      just tried your solution ..works great!!

      Comment

      • gomzi
        Contributor
        • Mar 2007
        • 304

        #4
        Originally posted by DutchKingCobra
        hi pal

        first dont use innerText as firefox does not use it
        as for your question
        Code:
        str='what a great \"score';
        
        iddiv=document.getElementById('mydiv')
        
        iddiv.innerHTML=str;
        well HTH
        peace

        Tried it in firefox. the innerHTML solution doesnt help much..firefox is not displaying anything.. in ie and opera it works great..

        Comment

        • DutchKingCobra
          New Member
          • Mar 2007
          • 37

          #5
          hmm works for me in IE and FF ?

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by gomzi
            Tried it in firefox. the innerHTML solution doesnt help much..firefox is not displaying anything.. in ie and opera it works great..
            There must be something else wrong with some other part of your code. For example, are you using document.all anywhere?

            Comment

            Working...