Page Loading

liunx

Guest
A simple question - I feel stupid posting it .. can anyone help me with proper language (I'm assuming it's HTML - may be Javascript?) for automatically loading an 'htm' page residing locally? Based upon screen resolution, I'd like to have certain pages automatically load without the need to "click on a link." I have the javascript code to determine screen resolution, but I'd like to automatically load the proper page associated with the screen resolution in use by the user.<br />
<br />
Thanks ...<br />
<br />
Bruce Larrabee<br />
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --><!--content-->When the following page is loaded the script checks the users screen resolution and loads the appropriate page<br />
<br />
<br />
<br />
<HTML><br />
<HEAD><br />
<TITLE>Document Title</TITLE><br />
<br />
<script language="javascript"><br />
<!--<br />
function chk_res(){<br />
w=screen.width<br />
if(w>=1024){<br />
window.open("yourpage1.htm",'','toolbar=no location=no directories=no status=no menubar=no scrollbars=yes resizable=no')<br />
}<br />
else{<br />
window.open("yourpage2.htm",'','toolbar=no location=no directories=no status=no menubar=no scrollbars=yes resizable=no')<br />
}<br />
}<br />
// --><br />
</script><br />
</HEAD><br />
<BODY><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"javascript:chk_res()">Open Page</a><br />
</BODY><br />
</HTML><!--content-->Two points:<br />
1. It's usually a lot easier to design one version of your site in a flowing style, so it works on any resolution.<br />
2. Your pages need to work with Javascript disabled if at all possible, so use this link code, which will work with JS disabled:<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"yourpage1.htm" onclick="chk_res();return false">Open Page</a><br />
<br />
Adam<!--content-->yep sorry about that I don't usually post links that way and the fact that it hasn't rendered correctly in this post<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"#null" onclick="chk_res()">Open Page</a><br />
<br />
:cool:<!--content-->Originally posted by Mr J<br />
yep sorry about that I don't usually post links that way and the fact that it hasn't rendered correctly in this post<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"#null" onclick="chk_res()">Open Page</a><br />
<br />
I don't think that's quite what was meant; by using your code the link will do nothing for none- JavaScript browsers. Using AdamGundry's code will allow the JavaScript function to execute, and will allow the HTML href to execute if the JavaScript doesn't, so that it works for more people.<!--content-->This is where I show my ignorance but how many people use non javascript browsers.<br />
<br />
Literally every webpage you go on has some sort of javascript in it.<br />
<br />
Javascript is as much part of the internet as HTML and CSS.<!--content-->Javascript is as much part of the internet as HTML and CSS. Except HTML and CSS work (when properly created) for virtually every web user, whether they use the latest version of IE or a text-based browser like Lynx. Javascript does not work for about 13% of web users, having disabled it due to choice or disability.<br />
<br />
From the W3C Web Content Accessibility Guidelines (<!-- m --><a class="postlink" href="http://www.w3.org/TR/WCAG10/">http://www.w3.org/TR/WCAG10/</a><!-- m -->):<br />
10.1 Until user agents allow users to turn off spawned windows, do not cause pop-ups or other windows to appear...Adam<!--content-->
 
Back
Top