📄 pagebanner.ascx
字号:
<%@Control Language="C#" EnableViewState="False" %>
<script runat="server">
// property declarations
public String UAType = "Unknown";
public String UAVer = "Unknown";
public Boolean Animate = false;
private String sBannerType = "Base";
private int iUAVer;
void Page_Load() {
// if Animate property is True get client type
if (Animate) {
try {
iUAVer = int.Parse(UAVer);
}
catch {
iUAVer = 0;
}
// see if the current client is Internet Explorer
if (UAType == "IE") {
if (iUAVer == 4 || iUAVer == 5) {
sBannerType = "IE4";
}
if (iUAVer >= 6) {
sBannerType = "IE6";
}
}
// see if the current client is Navigator
if (UAType == "Netscape") {
if (iUAVer == 4) { // version 4 only
sBannerType = "N4";
}
if (iUAVer >= 5) { // version 5/6+
sBannerType = "N6";
}
}
// see if the current client is Opera
if (UAType == "Opera" && iUAVer >= 6) {
sBannerType = "O6";
}
// insert the approprate block of code into the page
// currently opera has a problem with positioning, but
// should be able to use blockStd section when fixed
// also add "onload" attribute to <body> tag in main page
HtmlGenericControl oBodyTag;
switch (sBannerType) {
case "IE4":
oBodyTag = (HtmlGenericControl)Parent.FindControl("BodyTag");
oBodyTag.Attributes.Add("onload", "startAnimation()");
blockIE4.Visible = true;
break;
case "N6":
case "IE6":
// plus Opera6 when fixed
oBodyTag = (HtmlGenericControl)Parent.FindControl("BodyTag");
oBodyTag.Attributes.Add("onload", "startAnimation()");
blockStd.Visible = true;
break;
case "N4":
oBodyTag = (HtmlGenericControl)Parent.FindControl("BodyTag");
oBodyTag.Attributes.Add("onload", "startAnimation()");
blockN4.Visible = true;
break;
default:
blockBase.Visible = true;
break;
}
}
else {
// no animation required, show base version
blockBase.Visible = true;
}
}
</script>
<table id="tblBack"
background="images/bgmain.gif" style="width:100%"
width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr><td nowrap="nowrap">
<asp:Literal id="blockIE4" runat="server" Visible="False">
<!-- animated page banner for IE 4.x and 5.x only -->
<img src="images/bgsizer.gif" width="1px" height="83px" alt="" />
<img id="CarImg" src="images/animtow1.gif" width="134px" height="61px" alt=""
style="visibility:hidden; position:absolute; display:block; left:0px; top:8px" />
<img id="CarImg2" src="images/animtow2.gif" width="134px" height="61px" alt=""
style="visibility:hidden; position:absolute; display:block; left:0px; top:8px" />
<img id="HeadImg" src="images/wccheader.gif" width="370px" height="61px" alt="Xrox Car Company"
style="visibility:hidden; position:absolute; display:block; left:0px; top:8px" />
<img id="Force" src="images/force.gif" width="200px" height="40px" alt="The Driving Force"
style="visibility:hidden; position:absolute; display:block; left:420px; top:15px" />
<script language="JavaScript">
<!--
//--- Version for Internet Explorer 4.x and 5.x only ---
//--- Uses IE-specific DHTML methods and properties ---
// declare the global variables
var objTimer; // reference to window.setInterval timer
var objCar; // reference to old car image
var objHead; // reference to Xrox Car Co banner image
var bLoaded; // flag to show if images are finished loading
var bSwapped; // flag to show we've swapped to the 2nd car image
var iWindowWidth; // width of client window
function startAnimation() {
window.status = 'Welcome to the Xrox Car Company';
objCar = document.all['CarImg'];
iCarLeft = - 150;
objHead = document.all['HeadImg'];
iHeadLeft = -520;
bSwapped = false; // using first car image
// need width of page to detect car reaching right-hand side
// table holding contents of page is sized to 100% of page width
iWindowWidth = document.all['tblBack'].style.pixelWidth;
// start the interval timer
objTimer = window.setInterval('moveImages()', 10);
}
function moveImages() {
// wait until all images have loaded (IE only)
if ((document.all) && document.readyState != 'complete') return;
// make the images visible, they're off screen
objCar.style.visibility = 'visible';
objHead.style.visibility = 'visible';
if (iCarLeft > iWindowWidth - 135) {
// car has got to right hand end
window.clearInterval(objTimer); // so stop timer
objCar.style.visibility = 'hidden'; // and hide it
window.status = 'Select a car for more information';
// display the slogan image
document.all['Force'].style.visibility = 'visible';
}
else {
// move the images
iCarLeft += 1;
objCar.style.left = iCarLeft;
if (iHeadLeft < 10) {
iHeadLeft += 1;
objHead.style.left = iHeadLeft;
}
else {
if (! bSwapped) {
// swap to the second car image (no towrope)
objCar.src = document.all['CarImg2'].src;
bSwapped = true;
}
}
}
}
//-->
</script>
</asp:Literal>
<asp:Literal id="blockStd" runat="server" Visible="False">
<!-- animated page banner for IE 6.x, Nav 6.x and above -->
<!-- NOTE: also Opera6+ when positioning error is fixed -->
<img src="images/bgsizer.gif" width="1px" height="83px" alt="" />
<img id="CarImg" src="images/animtow1.gif" width="134px" height="61px" alt=""
style="visibility:hidden; position:absolute; display:block; left:0px; top:8px" />
<img id="CarImg2" src="images/animtow2.gif" width="134px" height="61px" alt=""
style="visibility:hidden; position:absolute; display:block; left:0px; top:8px" />
<img id="HeadImg" src="images/wccheader.gif" width="370px" height="61px" alt="Xrox Car Company"
style="visibility:hidden; position:absolute; display:block; left:0px; top:8px" />
<img id="Force" src="images/force.gif" width="200px" height="40px" alt="The Driving Force"
style="visibility:hidden; position:absolute; display:block; left:420px; top:15px" />
<script language="JavaScript">
<!--
//--- Version for IE 6.0 and higher, Netscape 6.0 and ---
//--- higher, Mozilla 6.0 and higher, plus Opera 6.0. ---
//--- Uses W3CDOM Level2 + CSS methods and properties ---
// declare the global variables
var objTimer; // reference to window.setInterval timer
var objCar; // reference to old car image
var objHead; // reference to Xrox Car Co banner image
var bLoaded; // flag to show if images are finished loading
var bSwapped; // flag to show we've swapped to the 2nd car image
var iWindowWidth; // width of client window
function startAnimation() {
window.status = 'Welcome to the Xrox Car Company';
objCar = document.getElementById('CarImg');
iCarLeft = - 150;
objHead = document.getElementById('HeadImg');
iHeadLeft = -520;
bSwapped = false; // using first car image
// need width of page to detect car reaching right-hand side
// table holding contents of page is sized to 100% of page width
// use this except in Navigator 4 where we have to use the
// innerWidth property of the window instead:
if (document.all)
iWindowWidth = document.getElementById('tblBack').style.pixelWidth
else
iWindowWidth = window.innerWidth;
// start the interval timer
objTimer = window.setInterval('moveImages()', 10);
}
function moveImages() {
// wait until all images have loaded (IE only)
if ((document.all) && document.readyState != 'complete') return;
// make the images visible, they're off screen
objCar.style.visibility = 'visible';
objHead.style.visibility = 'visible';
if (iCarLeft > iWindowWidth - 135) {
// car has got to right hand end
window.clearInterval(objTimer); // so stop timer
objCar.style.visibility = 'hidden'; // and hide it
window.status = 'Select a car for more information';
// display the slogan image
document.getElementById('Force').style.visibility = 'visible';
}
else {
// move the images
iCarLeft += 1;
objCar.style.left = iCarLeft;
if (iHeadLeft < 10) {
iHeadLeft += 1;
objHead.style.left = iHeadLeft;
}
else {
if (! bSwapped) {
// swap to the second car image (no towrope)
objCar.src = document.getElementById('CarImg2').src;
bSwapped = true;
}
}
}
}
//-->
</script>
</asp:Literal>
<asp:Literal id="blockN4" runat="server" Visible="False">
<!-- animated page banner for N4.x only -->
<img src="images/bgsizer.gif" width="1px" height="83px" alt="" />
<layer id="HeadLayer" top="15px" left="-520px" visibility="hidden">
<img src="images/wccheader.gif" width="370px" height="61px" alt="Xrox Car Company" />
</layer>
<layer id="CarLayer" top="15px" left="-150px" visibility="hidden">
<img src="images/animtow1.gif" width="134px" height="61px" alt="" />
</layer>
<layer id="ForceLayer" top="25px" left="430px" visibility="hidden">
<img src="images/force.gif" width="200px" height="40px" alt="The Driving Force" />
</layer>
<layer id="Car2Layer" top="15px" left="383px" visibility="hidden">
<img src="images/animtow2.gif" alt="" />
</layer>
<script language="JavaScript">
<!--
//--- Version for Netscape Navigator 4.x only ---
//--- Uses Netscape-specific layers + methods ---
// declare the global variables
var objTimer; // reference to window.setInterval timer
var layHead; // reference to Xrox Car Co banner image layer
var layCar; // reference to old car (with towrope) image layer
var layCar2; // reference to old car (no towrope) image layer
var layForce; // reference to slogan layer
var bSwapped; // flag to show we've swapped to the 2nd car image
var iWindowWidth; // width of client window
function startAnimation() {
window.status = 'Welcome to the Xrox Car Company';
layHead = document.layers['HeadLayer'];
layCar = document.layers['CarLayer'];
layCar2 = document.layers['Car2Layer'];
layForce = document.layers['ForceLayer'];
bSwapped = false; // using first car image
iWindowWidth = window.innerWidth;
// start the interval timer
objTimer = window.setInterval('moveImages()', 10);
}
function moveImages() {
// make the images visible, they're off screen
layCar.visibility = "visible";
layHead.visibility = "visible";
if (layCar.left > iWindowWidth - 50) {
// car has got to right hand end
window.clearInterval(objTimer); // so stop timer
layCar.visibility = 'hidden'; // and hide it
window.status = 'Select a car for more information';
layForce.visibility = "visible"; // show slogan
}
else {
// move the images
layCar.moveToAbsolute(layCar.left + 1, layCar.top);
if (layHead.left < 20)
layHead.moveToAbsolute(layHead.left + 1, layHead.top);
else {
if (! bSwapped) {
// swap to the second car image (no towrope)
layCar.visibility="hidden";
layCar = layCar2;
layCar.visibility="visible";
bSwapped = true;
}
}
}
}
//-->
</script>
</asp:Literal>
<asp:Literal id="blockBase" runat="server" Visible="False">
<!-- page banner with no animation -->
<img src="images/wccheader.gif" width="370"
height="61" hspace="10" vspace="8" alt="Xrox Car Company" />
<img src="images/force.gif" width="200"
height="40" hspace="20" vspace="5" alt="The Driving Force" />
</asp:Literal>
</td></tr>
</tbody>
</table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -