Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool Looping and so on ...

    Hi all,

    I have a problems with some national characters.. I'm using proper charset I think
    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
    and all characters work properly like , ć, etc. I have a small problem when I'm taking rss from another website .. in this case national characters appear like ? ... my question is should I write javascript (I don't know how to write it I'm still newbie with javascripts) which will loop trough body and replace all national characters if any with proper html symbol like
    ć is same as &# 263;
    or another better solution is out there.

    Thank you for your answers

  • #2
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    Code:
     
    function strCode(str){
    for(var a = 0; a < str.length; a++){
        var tmp = str.substr(a, 1);
        var output = "";
        switch(tmp){
            case "your_char_for_replacement":
                output += "your_converted_char";
                break;
            //more cases like the one above as needbe
            default:
                output += tmp;
                break;
        }
    }
    return output;
    }
    document.getElementById("your_container").innerHTML = strCode(document.getElementById("your_container").innerHTML);
    not 100&#37; certain on this, but instead of a switch you may be able to do output += "&#"+tmp.charCodeAt(0)+";";
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • Users who have thanked mjlorbet for this post:

    c0mrade (04-22-2008)

  • #3
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thank you I think this will be very useful if not now will be later because I'm always encountering these kind of problems... just one more question ... since I don't have one big container which contains all parts of website I have header, body and footer all separated .. can I apply this to whole body ... sth. like
    Code:
    <body onload="strCode(this);">
    sorry because this probably doesn't make sense but I'm trying to be accurate as I can thank you again for your time

  • #4
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    i suppose you could do that, but the this keyword doesn't make sense in that context as the parameter would be the id of the element to be passed, so you would have to assign an id to the body tag and pass the id you set

    Code:
     
    <body id="myBody" onload="strCode('myBody');">
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender


  •  

    Posting Permissions

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