Programalama > JAVA SCRIPT

Etiketler: hareketli, menü.

Ort. 0
Puan ver:
// 1.js 

var NS4 = (document.layers) ? true : false; 
var IE4 = (document.all) ? true : false; 

var interval = 20; 
var increment = 1; 
var pause = 750; 
var bannerColor = "#FFFFFF"; 
var leftPadding = 3; 
var topPadding = 1; 

var bannerLeft = (NS4) ? document.images.holdspace.x : 
  holdspace.offsetLeft; 
var bannerTop = (NS4) ? document.images.holdspace.y : 
  holdspace.offsetTop; 
var bannerWidth = (NS4) ? document.images.holdspace.width : 
  holdspace.width; 
var bannerHeight = (NS4) ? document.images.holdspace.height : 
  holdspace.height; 

var ar = new Array( 
  '<A HREF=""STYLE="color:CDCA0f;font-size:20pt;font-family:Arial Black;" >Universal JavaScript Rollovers</A>', 
  '<A HREF=""STYLE="color:444A0f;font-size:20pt;font-family:Arial Black;">Mastering JavaScript Dates</A>', 
  '<A HREF=""STYLE="color:00FFA0;font-size:20pt;font-family:Arial Black;" 
>Rotating Text Banners</A>', 
  '<A HREF=""STYLE="color:000000;font-size:20pt;font-family:Arial Black;">Text Rollovers</A>', 
  '<A HREF=""STYLE="color:0FD0A3;font-size:20pt;font-family:Arial Black;">Regular Expressions</A> ', 
  '<A HREF="" STYLE="color:fEDA0f;font-size:20pt;font-family:Arial Black;">Browser Compatibility</A>', 
  '<A HREF=""STYLE="color:0066ff;font-size:20pt;font-family:Arial Black;">Window Spawning and Remotes</A>', 
  '<A HREF=""STYLE="color:ff0000;font-size:20pt;font-family:Arial Black;">Crispy JavaScript Cookies</A>', 
  '<A HREF=""STYLE="color:30FFFF;font-size:20pt;font-family:Arial Black;">The Navigator Event Model</A>', 
  '<A HREF=""STYLE="color:FF9800;font-size:20pt;font-family:Arial Black;">The Internet Explorer Event Model</A>', 
  '<A HREF=""STYLE="color:FF68FF;font-size:20pt;font-family:Arial Black;">The Cross-Browser Event Model</A>', 
  '<A HREF=""STYLE="color:22F900;font-size:20pt;font-family:Arial Black;">JavaScript Selections</A>' 
); 
  

2.js Dosyası.Bu kodlar 2.js adıyla kaydedilecektir. 

// 2.js 

onload = startBanner; 

function showMessage(n, show) { 
  var whichEl = (NS4) ? eval("message" + n) : 
                        eval("message" + n + ".style"); 
  whichEl.visibility = (show) ? ((NS4) ? "show" : "visible") : 
                                ((NS4) ? "hide" : "hidden"); 
} 

function nextMessage() { 
  var fromInd = current; 
  current = (fromInd == ar.length - 1) ? 0 : fromInd + 1; 
  scrollBanner(fromInd, current); 
} 

function moveUp() { 
  if (NS4) { 
    fromEl.top -= increment; 
    if (toEl.top - increment <= toElTarget) { 
      toEl.top = toElTarget; 
      clearInterval(intervalID); 
      fromEl.visibility = "hide"; 
      timeoutID = setTimeout("nextMessage()", pause); 
    } else { 
      toEl.top -= increment; 
    } 
  } else { 
    fromEl.pixelTop -= increment; 
    if (toEl.pixelTop - increment <= toElTarget) { 
      toEl.pixelTop = toElTarget; 
      clearInterval(intervalID); 
      fromEl.visibility = "hidden"; 
      timeoutID = setTimeout("nextMessage()", pause); 
    } else { 
      toEl.pixelTop -= increment; 
    } 
  } 
} 

function scrollBanner(from, to) { 
  if (NS4) { 
    fromEl = eval("message" + from); 
    toEl = eval("message" + to); 
    toEl.top = fromEl.top + bannerHeight; 
    toElTarget = fromEl.top; 
  } else { 
    fromEl = eval("message" + from + ".style"); 
    toEl = eval("message" + to + ".style"); 
    toEl.pixelTop = fromEl.pixelTop + bannerHeight; 
    toElTarget = fromEl.pixelTop; 
  } 
  showMessage(to, true); // show the upcoming message 
  intervalID = setInterval("moveUp()", interval); 
} 

function makeIE() { 
  // assign the necessary code to a variable 
  var text = '<DIV ID="banner" STYLE="position:absolute">'; 
  for (var i = ar.length - 1; i >= 0; i--) { 
    text += '<DIV ID="message' + i +  
            '" STYLE="position:absolute"></DIV>'; 
  } 
  text += '</DIV>'; 

  // insert the code before the end of the document 
  document.body.insertAdjacentHTML("BeforeEnd", text); 

  // define the main element's properties 
  with (banner.style) { 
    width = bannerWidth; 
    height = bannerHeight; 
    clip = "rect(0 " + bannerWidth + " " + bannerHeight + " 0)"; 
    backgroundColor = bannerColor; 
    pixelLeft = bannerLeft; 
    pixelTop = bannerTop; 
  } 

  // define the child elements' properties 
  for (i = 0; i < ar.length; i++) { 
    with (eval("message" + i + ".style")) { 
      visibility = "hidden"; 
      pixelLeft = leftPadding; 
      pixelTop = topPadding; 
      width = bannerWidth - leftPadding; 
      backgroundColor = bannerColor; 
    } 
  } 
} 

function makeNS() { 
  // create the main element 
  banner = new Layer(bannerWidth); 

  // define the main element's properties 
  with (banner) { 
    clip.right = bannerWidth; 
    clip.bottom = bannerHeight; 
    document.BGCOLOR="#000000"Color = bannerColor; 
    left = bannerLeft; 
    top = bannerTop; 
    visibility = "show"; 
  } 

  // define the child elements' properties 
  for (var i = 0; i < ar.length; i++) { 
    // create a child element 
    eval("message" + i + " = " +  
         "new Layer(bannerWidth - leftPadding, banner)"); 
    with(eval("message" + i)) { 
      visibility = "hide"; 
      left = leftPadding; 
      top = topPadding; 
      document.BGCOLOR="#000000"Color = bannerColor; 
    } 
  } 
} 

function fillBanner() { 
  var whichEl; 
  if (NS4) { 
    for (var i = 0; i < ar.length; i++) { 
      whichEl = eval("message" + i); 
      whichEl.document.write(ar[i]); 
      whichEl.document.close(); 
    } 
  } else { 
    for (var i = 0; i < ar.length; i++) { 
      whichEl = eval("message" + i); 
      whichEl.innerHTML = ar[i]; 
    } 
  } 
} 

function startBanner() { 
  if (NS4) 
    makeNS() 
  else 
    makeIE(); 
  fillBanner(); 
  showMessage(0, true); 
  current = 0; 
  timeoutID = setTimeout("nextMessage()", pause); 
} 

1Adım:Aşağıdaki  JavaScrip kodlamasını sayfada <Head>.. </Head> tag'ının arasına gelecek şekilde yazın.  
2.Adım:Kodlamada kullanılan ve sayfada görünmesi istenen bannerin java script kodları 1.js ve 2.js adıyla sayfaya dışarıdan dahil edilecektir. 

<P><IMG SRC="blank.gif" 
        NAME="holdspace" ID="holdspace" 
        WIDTH="550" HEIGHT="35" 
        STYLE="visibility:hidden; position:relative;"></P> 
<SCRIPT LANGUAGE="JavaScript1.2"> 
<!-- 

if (navigator.appVersion.indexOf("MSIE 4.0; Macintosh;") == -1) { 
  with (document) { 
    write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='1.js'>"); 
    write("<\/SCRIPT>"); 
    write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='2.js'>"); 
    write("<\/SCRIPT>"); 
  } 
} 

//--> 
</SCRIPT>


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.