我不知道我在这里错过了什么。我想做一个响应屏幕分辨率的javascript,但我无法让它工作。任何输入?
<SCRIPT LANGUAGE="javascript">
if (screen.width <= 479)
{document.write("Less tgab 479");}
if (screen.width <= 480 && <= 767)
{document.write("Between 480 and 767")}
if (screen.width <= 768 && <= 989)
{document.write("Between 768 and 989")}
if (screen.width >= 990)
{document.write("Above 990")}
</SCRIPT>
感谢所有帮助。
这应该有效
if (screen.width <= 479) {document.write("Less tgab 479");}
if (screen.width >= 480 && screen.width <= 767) {document.write("Between 480 and 767")}
if (screen.width >= 768 && screen.width <= 989) {document.write("Between 768 and 989")}
if (screen.width >= 990) {document.write("Above 990")}
问题是你在第二个和第三个有错误的条件,如果
screen.width >= 480 && screen.width<= 767
screen.width >= 768 && screen.width<= 989
你的 ands 简写不起作用,你必须明确地写出每个条件。你也得到了第一个条件倒过来
由此:
if (screen.width <= 480 && <= 767)
{document.write("Between 480 and 767")}
对此:
if (screen.width >= 480 && screen.width < 768)
{document.write("Between 480 and 767")}