Hello,
The goal of this script is to display a 800x600 image in full screen depending on the users resolution.
This background image must fit the navigator window, no white space on the right or at bottom.
I could use a 100 % width and height in a 100 % Width and Height table, but
it is buggy on all navigators except IE.
So i am using this script below.
---------------------------------------------
It stretches a div containing the image on all the available screen width.
----------------------------------------------
<div id="backgroundLayer" style="position:absolute; width:694px;
height:331px; z-index:1; left: 0px; top: 0; visibility: visible">
<SCRIPT LANGUAGE="JavaScript">
if(is.ns4 || is.ns6) {
available_width = innerWidth;
available_height = innerHeight;
}
else if(is.ie4 || is.ie5 || is.ie55 || is.ie6) {
available_width=document.body.clientWidth;
available_height=document.body.clientHeight;
}
if(is.ie4 || is.ie5 || is.ie55 || is.ie6 || is.ns6 || is.ns4) {
image1_width = (available_width * 1.00);
image1_height = (image1_height * (available_width / image1_width));
var image1 = '<img src="1.jpg" width="' + image1_width
+ '" height="' + image1_height + '">';
document.write(image1);
}
</script>
</div>
-----------------------------------------------------
Of course I have to maintain the img proportions
when stretched: that is why i am using a ratio to calculate
the img height : image1_height = (image1_height * (available_width / image1_width))
Doesn't work in
MSIE
OPERA
none of the two are displaying the background image
Gives acceptable result ( displays and stretches the image )
NETSCAPE 7
MOZILLA
PHOENIX
very buggy in
NETSCAPE 4
Can somebody out there help me to debug this ?
Why is msie not displaying the image ?
---------------------------------------------
I also use this navigator detection script
----------------------------------------------
agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer')
== -1)
&& (agent.indexOf('compatible') == -1)));
this.ns2 = (this.ns && (this.major == 3));
this.ns3 = (this.ns && (this.major == 3));
this.ns4b = (this.ns && (this.major == 4) && (this.minor <= 4.03));
this.ns4 = (this.ns && (this.major == 4));
this.ns6 = (this.ns && (this.major >= 5));
this.ie = (agent.indexOf("msie"
!= -1);
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0"
== -1));
this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0"
!= -1));
this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5"
!= -1));
this.ie6 = (this.ie && (agent.indexOf("msie 6.0"
!=-1) );
this.aol = (agent.indexOf("aol"
!= -1);
this.aol3 = (this.aol && this.ie3);
this.aol4 = (this.aol && this.ie4);
this.aol5 = (this.aol && this.ie5);
}
var is = new Is();
function winResize() {
if(is.ns4 ||is.ns6||is.ie4||is.ie5||is.ie55||is.ie6) {
history.go(0);
}
}
Maybie the bug is in this part of the script ?
thanks for your incomming messages.
Hab.
The goal of this script is to display a 800x600 image in full screen depending on the users resolution.
This background image must fit the navigator window, no white space on the right or at bottom.
I could use a 100 % width and height in a 100 % Width and Height table, but
it is buggy on all navigators except IE.
So i am using this script below.
---------------------------------------------
It stretches a div containing the image on all the available screen width.
----------------------------------------------
<div id="backgroundLayer" style="position:absolute; width:694px;
height:331px; z-index:1; left: 0px; top: 0; visibility: visible">
<SCRIPT LANGUAGE="JavaScript">
if(is.ns4 || is.ns6) {
available_width = innerWidth;
available_height = innerHeight;
}
else if(is.ie4 || is.ie5 || is.ie55 || is.ie6) {
available_width=document.body.clientWidth;
available_height=document.body.clientHeight;
}
if(is.ie4 || is.ie5 || is.ie55 || is.ie6 || is.ns6 || is.ns4) {
image1_width = (available_width * 1.00);
image1_height = (image1_height * (available_width / image1_width));
var image1 = '<img src="1.jpg" width="' + image1_width
+ '" height="' + image1_height + '">';
document.write(image1);
}
</script>
</div>
-----------------------------------------------------
Of course I have to maintain the img proportions
when stretched: that is why i am using a ratio to calculate
the img height : image1_height = (image1_height * (available_width / image1_width))
Doesn't work in
MSIE
OPERA
none of the two are displaying the background image
Gives acceptable result ( displays and stretches the image )
NETSCAPE 7
MOZILLA
PHOENIX
very buggy in
NETSCAPE 4
Can somebody out there help me to debug this ?
Why is msie not displaying the image ?
---------------------------------------------
I also use this navigator detection script
----------------------------------------------
agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer')
== -1)
&& (agent.indexOf('compatible') == -1)));
this.ns2 = (this.ns && (this.major == 3));
this.ns3 = (this.ns && (this.major == 3));
this.ns4b = (this.ns && (this.major == 4) && (this.minor <= 4.03));
this.ns4 = (this.ns && (this.major == 4));
this.ns6 = (this.ns && (this.major >= 5));
this.ie = (agent.indexOf("msie"
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0"
== -1));
this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0"
!= -1));
this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5"
!= -1));
this.ie6 = (this.ie && (agent.indexOf("msie 6.0"
this.aol = (agent.indexOf("aol"
this.aol3 = (this.aol && this.ie3);
this.aol4 = (this.aol && this.ie4);
this.aol5 = (this.aol && this.ie5);
}
var is = new Is();
function winResize() {
if(is.ns4 ||is.ns6||is.ie4||is.ie5||is.ie55||is.ie6) {
history.go(0);
}
}
Maybie the bug is in this part of the script ?
thanks for your incomming messages.
Hab.