Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy Q: Same script 2x on one page

Status
Not open for further replies.

JoeM6

Programmer
Aug 5, 2000
53
0
0
US
gamecentral.20m.com
I want to put the following script on my page twice, in two different places:

<SCRIPT Language=VBScript>
if screen.height = 480 Then
document.write ('480')
End if
if screen.height = 600 Then
document.write ('600')
End if
if screen.height = 768 Then
document.write ('768')
End if
</SCRIPT>

It works fine by itself, but I dont know how to use it twice.

TIA, Joe

JoeM6
JPMJR11@aol.com
 
Hey,

How about putting the code in a
procedure? Then calling that
procedure on any event to
execute that code.
For example:

Code:
<BODY onLoad=&quot;Screen()&quot;>

<SCRIPT Language=VBScript>
Sub Screen()
   if screen.height = 480 Then
      document.write ('480')    
   End if
   if screen.height = 600 Then
      document.write ('600')
   End if
   if screen.height = 768 Then
      document.write ('768')    
   End if    
End Sub
</SCRIPT>

karmafree
 
Yes thank you, that works. I also figured out I could do it like this because I am also working with ASP:
<SCRIPT Language=VBScript>
if screen.height = 480 Then
<%
resolution = &quot;480&quot;
%>
End if
if screen.height = 600 Then
<%
resolution = &quot;600&quot;
%>
End if
if screen.height = 768 Then
<%
resolution = &quot;768&quot;
%>
End if
</SCRIPT>

Then, wherever I want the resolution to be displayed, I could do

response.write &quot;&quot; & resolution & &quot;&quot;

Thanks for the help

JoeM6
JPMJR11@aol.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top