How can i get the client screen width?

ruvik
06-11-2002, 03:59 AM
Hi all,

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

Thanks,
Ruvik

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


x = screen.width


Good Luck
-CL

ruvik
06-12-2002, 02: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 :)

Thanks,
Ruvik

Agent
06-12-2002, 07:04 AM
Ruvik,

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. ;)

ruvik
06-12-2002, 10: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",
lgvOptions,"330",SCREEN.WIDTH)%>
</TD>

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?)

Ruvik

Agent
06-12-2002, 11: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.

http://www.google.com
http://www.yahoo.com

Derek Stone
06-12-2002, 11: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
-CL

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

Serevinus
06-13-2002, 05: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">
<HTML>
<HEAD>
<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
</SCRIPT>
<%End If%>
</HEAD>

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

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

Nattyboy
06-14-2002, 04: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

ruvik
06-16-2002, 12:42 AM
Hey guys,
Thank you all very much. I checked it and it works fine.
Appreciate your help,
Ruvik

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum