How can i get the client screen width?

06-11-2002, 02:59 AM
Hi all,

I need to know the client screen width. Is it possible?


Derek Stone
06-11-2002, 07:23 PM
It can be determined through JavaScript:

x = screen.width

Good Luck

06-12-2002, 01:07 AM
Thanks, but can anyone help me in using that in a table?

suppose i have the screen.width

var x
x = screen.width

i need a table whose width is the screen.width, something like:

<table width=x> - how can i use this variable in html/asp/vbscript/javascript

im kind of new to internet programming, so sorry if i ask stupid questions :)


06-12-2002, 06:04 AM

I couldn't tell you how to use that variable (which I think is
undefined) in the table attribute width. I do understand
what your doing though. Try this. In the body tag of your
document, add...
marginwidth="0" marginheight="0" topmargin="0" leftmargin="0"
Then, in your table tag, use percents...
<table width="100%">
<!-- or it might be... -->
<table width=100%>

Always remember, with good old html you can always look
at their source to see how they do things. ;)

06-12-2002, 09:08 AM
Thanks, but I have to use the variable which holds the screen.width .
Using width=100% cant help me much. Is there a way to use a variable within html?

<TD class="TableData">
<%=CreateTreeView" OmsWeb.PCatalog" ,"ProductCatalog",

I need to send to the function CreateTreeView the screen.width variable which holds the CLIENT screen.width

What is the right way to write this code (if there is a way?)


06-12-2002, 10:11 AM
Are you going to cry if you don't use javascript? The 100% works
for me. :)

You need to try to search for a javascript tutorial it seems.

Derek Stone
06-12-2002, 10:18 AM
You're trying to use a JavaScript command in VBScript. That's not going to work out. If you insist on retrieving a browser's dimensions you'll need to create a page that is loaded by the browser and sends the dimensions back to the server using either Get or Post.

Good Luck

06-13-2002, 02:28 AM
I'll search in a few tutorials.
Thanks all,

06-13-2002, 04:43 PM
The way I did it when i needed to do somthing similar was to do this

filename is jstable.asp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<TITLE>Dynamic Table Test</TITLE>
<META name="LANGUAGE" content="en">
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<%If Request.QueryString("width") = "" Then%>
<SCRIPT type="text/javascript" language="javascript">
document.location="jstable.asp?width=" + screen.width
<%End If%>

<%If Request.QueryString("width") <> "" Then%>
<TABLE border="1" width="<%=Request.QueryString("width")%>">
<TD>Cell A</TD>
<TD>Cell B</TD>
<TD>Cell C</TD>
<TD>Cell D</TD>
Anyone without JavaScript enabled will see this
<%End If%>

I think this has the result you are looking for, but may not be the best way to do it
I think this is what Crazed Lunatic was suggesting

06-14-2002, 03:44 AM
it was nice piece of code Serevinus

i have checked it up and it works v.good and i just recommend few modification in that code for fine tuning

<!-- Replace the Body tag with this -->
<BODY marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
<!-- Replace the Table tag like this and Subtracting 20 so that it fits in the screen .. check it up -->
<TABLE border="1" width="<%=Request.QueryString("width") - 20%>">

ruvik did u checked the code ?

- Nattyboy

06-15-2002, 11:42 PM
Hey guys,
Thank you all very much. I checked it and it works fine.
Appreciate your help,

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum