admin 管理员组文章数量: 1086019
I am developing a web application using PHP,Smarty for a french client. I am facing a problem in java script alert and confirm boxes. How can I use HTML special characters in javascript message boxes. This is my code
<script type="text/javascript">
function delConfirm(key){
if(confirm('Êtes vous certain de vouloir supprimer ce client ?')){
window.location = "deleteClient.php?e="+key;
}
}
</script>
This is the page source of the first part of the page. Please take a look at the encoding section too,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Sunil">
I am developing a web application using PHP,Smarty for a french client. I am facing a problem in java script alert and confirm boxes. How can I use HTML special characters in javascript message boxes. This is my code
<script type="text/javascript">
function delConfirm(key){
if(confirm('Êtes vous certain de vouloir supprimer ce client ?')){
window.location = "deleteClient.php?e="+key;
}
}
</script>
This is the page source of the first part of the page. Please take a look at the encoding section too,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Sunil">
Share
Improve this question
edited Feb 2, 2013 at 15:53
Technosavia
asked Feb 2, 2013 at 15:41
TechnosaviaTechnosavia
852 silver badges12 bronze badges
2 Answers
Reset to default 7That's correct, because confirm
doesn't accept HTML. You can use unicode escape sequence in JavaScript, though. You can look up Unicode code point values here. The equivalent of Ê
is U+00CA
(it's on this chart), so:
if(confirm('\u00CAtes vous certain de vouloir supprimer ce client ?')){
window.location = "deleteClient.php?e="+key;
}
Alternately, ensure that your file is correctly encoded (in UTF-8 for example), that your editor understands files encoded in that way, and that the file is served correctly (the server tells the browser it's UTF-8), maybe even throw in a meta charset="xxx"
tag in the header for luck, and you can just type the French characters directly into the file.
Use this instead
<script type="text/javascript">
function delConfirm(key){
if(confirm('\u00CAtes vous certain de vouloir supprimer ce client ?')){
window.location = "deleteClient.php?e="+key;
}
}
</script>
本文标签: javascriptHTML special characters are not showing properly in jsStack Overflow
版权声明:本文标题:javascript - HTML special characters are not showing properly in js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1743999052a2516109.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论