J
joe
I am using the first script below, to add random images to my home
page.
I would like to be able to test the visitors screen size so that the
script can
change the pic_width and pic_height.
I have included a second script further down which does a test, but
which serves
different documents.
Can someone give me a simple solution to be able to adjust the first
script
please, so that I can keep it all on the same page?
I have no knowledge of javascript, so would appreciate it if changes
can be
placed in the text below.
TIA.
First script.
<SCRIPT language="JavaScript">
<!--
/* You can get this script and many others
by visiting JavaScript City at: http://www.javascriptcity.com . */
pic_width=800; /*change to match the height of all your images */
pic_height=600; /* change to match the width of all your images */
border_size=0; /* change to the border size you want on the images
*/
alignment=1; /* 0=left,1=center */
/* define image urls */
if (document.images)
{
pic1= new Image(pic_width,pic_height);
pic1.src="image1.jpg";
pic2= new Image(pic_width,pic_height);
pic2.src="image2.jpg";
pic3= new Image(pic_width,pic_height);
pic3.src="image3.jpg";
pic4= new Image(pic_width,pic_height);
pic4.src="image4.jpg";
pic5= new Image(pic_width,pic_height);
pic5.src="image5.jpg";
}
/* no need to edit past this point (unless you want to add more image
slots) */
if (alignment==1)
{
cent_it="<CENTER>";
cent_it2="<\/CENTER>";
}
else
{
cent_it="";
cent_it2="";
}
function get_random(maxNum)
{
if (Math.random && Math.round)
{
var ranNum= Math.round(Math.random()*(maxNum-1));
ranNum+=1;
return ranNum;
}
else
{
today= new Date();
hours= today.getHours();
mins= today.getMinutes();
secn= today.getSeconds();
if (hours==19)
hours=18;
var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
return ranNum;
}
}
function get_Image()
{
if (document.images)
{
var choose_one= get_random(5);
choose_one--;
var pics= new Array(5)
pics[0]=pic1.src;
pics[1]=pic2.src;
pics[2]=pic3.src;
pics[3]=pic4.src;
pics[4]=pic5.src;
document.write(cent_it+"<IMG SRC='"+pics[choose_one]+"'
width='"+pic_width+"'
height='"+pic_height+"' border='"+border_size+"'>"+cent_it2);
}
}
//-->
</SCRIPT>
#######################################################
Second script
<SCRIPT LANGUAGE="JavaScript">
/*
Made By Aviv Salem, (e-mail address removed)
*/
// browser test:
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if (browserName == "Netscape" && browserVer >= 4 || browserName ==
"Microsoft Internet Explorer" && browserVer >= 4)
version = "1";
else if (browserName == "Netscape" && browserVer >= 3)
version = "2";
else
version = "3";
if (version == "1") {
var correctwidth=800
var correctheight=600
if (screen.width<correctwidth||screen.height<correctheight)
location="PAGE_FOR_LOW_SIZE.htm"
else
location="PAGE_FOR_HIGH_SIZE.htm"
}
if (version == "2") {
var toolkit = java.awt.Toolkit.getDefaultToolkit();
var screen_size = toolkit.getScreenSize();
var correctwidth=800
var correctheight=600
if (screen_size.width<correctwidth||screen_size.height<correctheight)
location="PAGE_FOR_LOW_SIZE.htm"
else
location="PAGE_FOR_HIGH_SIZE.htm"
}
if (version == "3")
location="DEFAULT_PAGE.htm"
</SCRIPT>
page.
I would like to be able to test the visitors screen size so that the
script can
change the pic_width and pic_height.
I have included a second script further down which does a test, but
which serves
different documents.
Can someone give me a simple solution to be able to adjust the first
script
please, so that I can keep it all on the same page?
I have no knowledge of javascript, so would appreciate it if changes
can be
placed in the text below.
TIA.
First script.
<SCRIPT language="JavaScript">
<!--
/* You can get this script and many others
by visiting JavaScript City at: http://www.javascriptcity.com . */
pic_width=800; /*change to match the height of all your images */
pic_height=600; /* change to match the width of all your images */
border_size=0; /* change to the border size you want on the images
*/
alignment=1; /* 0=left,1=center */
/* define image urls */
if (document.images)
{
pic1= new Image(pic_width,pic_height);
pic1.src="image1.jpg";
pic2= new Image(pic_width,pic_height);
pic2.src="image2.jpg";
pic3= new Image(pic_width,pic_height);
pic3.src="image3.jpg";
pic4= new Image(pic_width,pic_height);
pic4.src="image4.jpg";
pic5= new Image(pic_width,pic_height);
pic5.src="image5.jpg";
}
/* no need to edit past this point (unless you want to add more image
slots) */
if (alignment==1)
{
cent_it="<CENTER>";
cent_it2="<\/CENTER>";
}
else
{
cent_it="";
cent_it2="";
}
function get_random(maxNum)
{
if (Math.random && Math.round)
{
var ranNum= Math.round(Math.random()*(maxNum-1));
ranNum+=1;
return ranNum;
}
else
{
today= new Date();
hours= today.getHours();
mins= today.getMinutes();
secn= today.getSeconds();
if (hours==19)
hours=18;
var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
return ranNum;
}
}
function get_Image()
{
if (document.images)
{
var choose_one= get_random(5);
choose_one--;
var pics= new Array(5)
pics[0]=pic1.src;
pics[1]=pic2.src;
pics[2]=pic3.src;
pics[3]=pic4.src;
pics[4]=pic5.src;
document.write(cent_it+"<IMG SRC='"+pics[choose_one]+"'
width='"+pic_width+"'
height='"+pic_height+"' border='"+border_size+"'>"+cent_it2);
}
}
//-->
</SCRIPT>
#######################################################
Second script
<SCRIPT LANGUAGE="JavaScript">
/*
Made By Aviv Salem, (e-mail address removed)
*/
// browser test:
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if (browserName == "Netscape" && browserVer >= 4 || browserName ==
"Microsoft Internet Explorer" && browserVer >= 4)
version = "1";
else if (browserName == "Netscape" && browserVer >= 3)
version = "2";
else
version = "3";
if (version == "1") {
var correctwidth=800
var correctheight=600
if (screen.width<correctwidth||screen.height<correctheight)
location="PAGE_FOR_LOW_SIZE.htm"
else
location="PAGE_FOR_HIGH_SIZE.htm"
}
if (version == "2") {
var toolkit = java.awt.Toolkit.getDefaultToolkit();
var screen_size = toolkit.getScreenSize();
var correctwidth=800
var correctheight=600
if (screen_size.width<correctwidth||screen_size.height<correctheight)
location="PAGE_FOR_LOW_SIZE.htm"
else
location="PAGE_FOR_HIGH_SIZE.htm"
}
if (version == "3")
location="DEFAULT_PAGE.htm"
</SCRIPT>