I need to include a file always that the screen browser would be greater or equal than 699px, for this I’m trying to use the following script:
<script type="text/javascript">
<!--
if (screen.width >= 699) {
document.write (" <!--#include virtual="/menu.asp"-->");
}
//-->
</script>
But nothing it does. Does anyone know how to get it work?
Best regards.
The include directive needs to be a part of the page before it gets to the web browser, and since the JavaScript executes in the web browser, it’s already too late for that. You might consider putting the include in the page, but hiding it in a
divwithstyle="display:none;", and then removing that using JavaScript when the page loads:Alternatively, you could use the same strategy with CSS Media Queries.
Edit: Example:
This will give you better performance, and it will automatically hide and show the content as the user resizes their browser window.