like the title suggests i want to turn an object into a string, the reasons are the following: i want to create an alert message saying that your browser is currently using another language as default. ive been learning code for a month and a half now, so i know this isnt the most optimal way to do this: here is the code:
<body>
<div class="container">
<script>
var lang= navigator.language;
if (""+ lang == es-US) {
alert ("Your browser is in spanish, change it");
}
</script>
Just put quotes around es-US:
<script>
var lang = navigator.language;
if ("" + lang == "es-US") {
alert ("Your browser is in spanish, change it");
}
</script>
哎呀,我没有意识到if (""+ lang == es-US)
在if (""+ lang == es-US)
没有""
标志。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.