SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Location
    Taiwan
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to replace “ in a string?

    I want to remove the left double quote () but had no luck. Is there a solution?

    Code:
    <p>“Lorem ipsum dolor sit amet, consectetur adipiscing elit.”</p>
    Code:
    var html = document.getElementsByTagName('p')[0].innerHTML;
    html = html.replace("“", "");

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    This seems to work as advertised on the tin, for me.

    Could there be something else causing the problem?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    <script type="text/javascript">
     
    // [url]http://www.sitepoint.com/forums/javascript-15/how-replace-%93-string-771893.html[/url]
     
     
    function sil() {
     
    var p = document.getElementsByTagName('p')[0].innerHTML;
     
     
    p = p.replace('"', '');
     
    alert(p);
     
     
    }
     
     
    </script>
     
    </head>
     
    <body>
     
    <p>" Metindeki sol çift tırnak işareti silinmiyor. Left double quote will not be deleted "</p>
     
     
     
    <input type="button" value="click me" onclick="sil()">

    Code JavaScript:
    <script type="text/javascript">
     
    // [url]http://www.sitepoint.com/forums/javascript-15/how-replace-%93-string-771893.html[/url]
     
     
    function sil() {
     
    var p = document.getElementsByTagName('p')[0];
     
     
    p.innerHTML = p.innerHTML.replace('"', '');
     
    alert(p.innerHTML);
     
     
    }
     
     
    </script>
     
    </head>
     
    <body>
     
    <p>" Metindeki sol çift tırnak işareti siliniyor. Left double quote will be deleted."</p>
     
     
    <input type="button" value="click me" onclick="sil()">

    replace('"', '');
    Bismillahirrahmanirrahîm
    Bizi doğru yola, kendilerine nimet verdiklerinin yoluna ilet; gazaba uğrayanların ve sapıklarınkine değil.

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Location
    Taiwan
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The left double quote is , not ".

  5. #5
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this
    Code:
    var html = document.getElementsByTagName('p')[0];
    html.innerHTML = html.innerHTML.replace("“", "");
    intsead of
    Code:
    var html = document.getElementsByTagName('p')[0].innerHTML;
    html = html.replace("“", "");
    I use Firefox 4.0b9



    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <script type="text/javascript">
    
    function sil() {
     
    var html = document.getElementsByTagName('p')[0].innerHTML;
    html = html.replace("“", "");
    alert(html); // left double quote
    
    }
    
    </script>
    
    <body>
    
    
    <p> “left double quote  </p>
    
    <input type="button" value="sil" onclick="sil()">
    Message box displays left double quote . But there is left double quatation mark in the paragraph.



    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <script type="text/javascript">
    
    function sil() {
     
    var html = document.getElementsByTagName('p')[0];
    html.innerHTML = html.innerHTML.replace("“", "");
    alert(html.innerHTML); // left double quote 
    
    }
    
    </script>
    
    <body>
    
    <p> “left double quote </p>
    
    <input type="button" value="sil" onclick="sil()">
    Message box displays left double quote . There is not left double quatation mark in the paragraph.
    Bismillahirrahmanirrahîm
    Bizi doğru yola, kendilerine nimet verdiklerinin yoluna ilet; gazaba uğrayanların ve sapıklarınkine değil.


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
  •