我不知道我在这里缺少什么。我想制作一个响应屏幕分辨率的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>
感谢所有帮助。
答案 0 :(得分:1)
这应该有效
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 &gt; = 480&amp;&amp; screen.width &lt; = 767
screen.width &gt; = 768&amp;&amp; screen.width &lt; = 989
答案 1 :(得分:0)
您对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")}