I have created a javascript file which is referenced from an html file. The script is looping and I am unable to break out of it.
What I want to do is to redirect files to different directories for different screen sizes. (I am working on building a responsive site).
The javascript file is;
I have tried adding index.html and window.location="http://what-do-christians-believe.co.uk/index.html"Code:if(screen.width<=499) { window.location="http://what-do-christians-believe.co.uk/mob_phone/"; exit(); } if(screen.width<=995) { window.location="http://what-do-christians-believe.co.uk/mob_devices/"; exit(); } else { window.location="http://what-do-christians-believe.co.uk/"; exit(); }
;
The link from the html file is; <script src="device.js"></script>
The javascript code works fine in small devices.
I think the problem is that the javascript code is read. The correct html file is opened and then the javascript is reread and the program loops.
How can I stop the looping?


Reply With Quote
Bookmarks