admin管理员组文章数量:1325326
How do you enter special characters in the title attribute of html?
My JavaScript code:
var link_english = document.createElement("img");
link_english.setAttribute("src", "images/english_out.png");
link_english.setAttribute("title", "The english version of Nauma"); //
link_english.className = "classEnglish";
My question is: How do I insert a special tag within the value of the title attribute?
Example:
link_english.setAttribute("title", "here I want to put a special character for a German letter, the " ü " ");
If it is a normal html file, no problem.
How do you enter special characters in the title attribute of html?
My JavaScript code:
var link_english = document.createElement("img");
link_english.setAttribute("src", "images/english_out.png");
link_english.setAttribute("title", "The english version of Nauma."); //
link_english.className = "classEnglish";
My question is: How do I insert a special tag within the value of the title attribute?
Example:
link_english.setAttribute("title", "here I want to put a special character for a German letter, the " ü " ");
If it is a normal html file, no problem.
Share Improve this question edited Feb 4, 2019 at 19:30 SherylHohman 18k18 gold badges93 silver badges96 bronze badges asked Apr 10, 2011 at 11:04 dimadima 311 gold badge1 silver badge3 bronze badges 2- What special characters? – BoltClock Commented Apr 10, 2011 at 11:06
- In what context? I don't understand. Please add more detail. – Pekka Commented Apr 10, 2011 at 11:07
2 Answers
Reset to default 4Just enter them.
You only need to ensure that the HTML page is saved using a character encoding which supports those characters (UTF-8 is preferred if you want world domination) and that the HTML page is been served over HTTP with a Content-Type
header which signifies the very same character encoding, so that the browser understands how to display them to the human, e.g text/html;charset=UTF-8
.
How to save the files the right way depends on the editor used, but usually this is available by Save As function and/or in the general editor settings. How to set the right HTTP content type header depends on the programming language and/or webserver used.
Update: the above answer still applies on your update. Save/serve file as UTF-8 and instruct browser by Content-Type
header to interpret it as UTF-8. This applies on JS files as good as on HTML files and other text based files.
Yes you can but to enter special character you have to use its HTML entity. Here is the table for special characters and its HTML entity.
本文标签: javascriptspecial characters in title tagStack Overflow
版权声明:本文标题:javascript - special characters in title tag - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742196936a2431251.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论