user1980542
user1980542

Reputation:

Foreign characters when loading external html code

I have the following javascript, loading my menu on all of my pages

    <script type = "text/javascript">
        $(document).ready(function () {
            $("#menudiv").load("menu.html");
        });
    </script>

I havent included the menu as it is a completely standard list, formatted to look like it does. One of the menu option contains the character "å", how can I make my page display this character correctly?

Upvotes: 0

Views: 88

Answers (3)

Charaf JRA
Charaf JRA

Reputation: 8334

add this HTML Meta tag in your page:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Or in HTML5 Way :

<meta charset="iso-8859-1">

Upvotes: 0

Aaron Digulla
Aaron Digulla

Reputation: 328594

This usually happens when the server doesn't set the encoding of menu.html correctly. Make sure the correct encoding is in the headers. (see this document) Especially, make sure that the Content-Type header is correct and that you have a <meta charset="..."> element in menu.html

The encoding of the existing page doesn't matter at all! Whenever you download something, the browser will look for the encoding of the new data, convert that to Unicode and only then, merge the new data with what it already has.

Upvotes: 2

Mr. Polywhirl
Mr. Polywhirl

Reputation: 48610

Add the following meta tag to the head of your HTML document:

<meta charset="iso-8859-1">

Use the HTML entity code for displaying this and other ISO characters:

&#229; or &aring;

More information on HTML entities from w3: http://www.w3schools.com/tags/ref_entities.asp

Upvotes: -1

Related Questions