Click to See Complete Forum and Search --> : Screen Resolution
Zaphod64831
Jun 21st, 2000, 08:32 AM
Does anyone know some code that will determine the screen resolution in VBScript?
I've got a navbar on my web page and the alignment of some of the links are off with some resolutions. Here is a sample of what I need:
If ScreenResolution > "800 X 600" Then Document.Write "<BR>"
I don't really have any VBScript experience, but I know it better than Javascript. I'll take any language I can get.
parksie
Jun 23rd, 2000, 06:49 PM
well, you can't use operators like that on a string - what you're doing is checking whether the string itself is greater. what you need is to chop it up, collect the different sizes, and compare them. alternatively, you can use Screen.Width and Screen.Height (I think).
billyo
Jun 24th, 2000, 01:12 AM
Ok, you still need the ==, but you also have to use parenthesis to enclose your argument for the document.write command. (document.write("blah") writes blah while .write(blah) writes the value of blah. If you try .write "blah"; it chokes. This code works. (&& is And)
<script language="JavaScript"><!--
if ((screen.width ==800)&&(screen.height ==600))
{
document.write ("600x800");
}
if ((screen.width ==1024)&&(screen.height ==768))
{
document.write ("768x1024");
}
//--></script>
Alternatively, if you're actually using the "<br>" tag to position an element on your page, you might try using a style sheet. So if you wanted to move a link:
<a id=thing_to_move href=#>click</a>
if ((screen.width ==800)&&(screen.height ==600))
{
document.write ("<style><!--#thing_to_move{position:absolute;left:50px;top:50px;}--></style>");
}
[Edited by billyo on 06-24-2000 at 03:01 PM]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.