alert乱码问题

很多朋友可能遇到这样的问题,在php文件中,大家可能经常这样用

echo "<script charset='utf-8' type='text/javascript'>alert('请登录');window.location.href='admin/index';</script>";

结果请登录显示出来的是乱码。

这里提供一种解决办法。

在这句语句上面加上echo "<meta http-equiv='Content-Type'' content='text/html; charset=utf-8'>";

注意里面的charset编码需要填写你网页对应的编码。实例如下:

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

echo "<script charset='utf-8' type='text/javascript'>alert('请登录');window.location.href='admin/index';</script>"; alert乱码问题

posted @ 2014-03-14 14:32  finary  阅读(394)  评论(0编辑  收藏  举报