Click to See Complete Forum and Search --> : Script like on Amazon.com homepage


polaatx2
08-03-2003, 03:28 PM
The Amazon.com homepage greets visitors with a script that slides an announcement layer into view and then pulls it back up. Does anyone know of a ready-made script that does that?

thanks.

crispy:confused:

Khalid Ali
08-03-2003, 03:54 PM
you could copy it from amazon's site ????

polaatx2
08-03-2003, 10:23 PM
Khalid,

I did but can't get it to work. It is so complicated I can't even understand exactly how they do it. Here's the script:

<SCRIPT language=JavaScript1.2>
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_aol = (agt.indexOf("aol") != -1);
var is_opera = (agt.indexOf("opera") != -1);
var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_ns4 = document.layers
var is_ns6 = document.getElementById&&!document.all
var is_ie4 = document.all
var is_opr = navigator.userAgent.indexOf("Opera")
var zindex=100
function amz_js_findPosX(obj) {
var curleft = 0;
if (document.getElementById || document.all) {
while (obj.offsetParent) {
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
} else if (document.layers) {
curleft += obj.x;
}
return curleft;
}
function amz_js_findPosY(obj) {
var curtop = 0;
if (document.getElementById || document.all) {
while (obj.offsetParent) {
curtop += obj.offsetTop
obj = obj.offsetParent;
}
} else if (document.layers) {
curtop += obj.y;
}
return curtop;
}
function amz_js_showselect(turnOn) {
if (is_ie4) {
var selects = document.all.tags("SELECT");
for (var i = 0; i < selects.length; i++) {
var thisSelect = selects[i];
var selectLeftPos = amz_js_findPosX(thisSelect);
var selectRightPos = selectLeftPos + thisSelect.offsetWidth;
var selectTopPos = amz_js_findPosY(thisSelect);
var selectBottomPos = selectTopPos + thisSelect.offsetHeight;
var menuLeftPos = amz_js_findPosX(rhh);
var menuRightPos = menuLeftPos + rhh.style.pixelWidth;
var menuTopPos = amz_js_findPosY(rhh);
var menuBottomPos = menuTopPos + 300;
var hideSelect = false;
if ( !( ( selectTopPos > menuBottomPos )
|| ( menuTopPos > selectBottomPos )
|| ( menuLeftPos > selectRightPos )
|| ( selectLeftPos > menuRightPos ) ) ) {
hideSelect = true;
}
if (turnOn || hideSelect) {
thisSelect.style.visibility = turnOn ? "visible" : "hidden";
}
}
}
}
function amz_js_hidemenu(){
if (is_ie&&window.themenu) {
themenuStyle.visibility="hidden";
amz_js_showselect(true);
}
}
function amz_js_dropmenu(e,menuID,xOffset,yOffset){
curmenuID=is_ns6? document.getElementById(menuID).id : eval(menuID).id
if (window.themenu&&themenu.id!=curmenuID) {
themenuStyle.visibility=is_ns4?"hide" : "hidden"
}
themenu=is_ns6? document.getElementById(menuID): eval(menuID)
themenuStyle=(is_ns6||is_ie4)? themenu.style : themenu
themenuoffsetX=(is_ie4&&is_opr==-1)? document.body.scrollLeft : 0
themenuoffsetY=(is_ie4&&is_opr==-1)? document.body.scrollTop : 0
themenuStyle.left=is_ns6||is_ns4? e.pageX-e.layerX+xOffset : themenuoffsetX+event.clientX-event.offsetX+xOffset
themenuStyle.top=is_ns6||is_ns4? e.pageY-e.layerY+yOffset : themenuoffsetY+event.clientY-event.offsetY+yOffset
amz_js_showselect(false);
hiddenconst=(is_ns6||is_ie4)? "hidden" : "hide"
if (themenuStyle.visibility==hiddenconst){
themenuStyle.visibility=(is_ns6||is_ie4)? "visible" : "show"
themenuStyle.zIndex=zindex++
} else {
amz_js_hidemenu();
}
return false;
}
if (is_ie) {
document.onclick=amz_js_hidemenu
}
</SCRIPT>

conma2cang
08-19-2003, 09:52 PM
has anyone know how to do this yet?