10 کد جدید و پر کاربرد جاوا اسکریپت

echessdesign

مدیر انجمن طراحی وب
مخفی کردن error های صفحه:
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide me from lame browsers

function CC_noErrors() {
return true;
}

window.onerror = CC_noErrors;

// -->
</SCRIPT>

صفحه مورد نظر شما در زمان مشخص refresh شود:
<script>

//refresh time is in "minutes:seconds"
var timer="0:30"

if (document.images){
var CoffeeParse=timer.split(":")
CoffeeParse=CoffeeParse[0]*60+CoffeeParse[1]*1
}
function refreshtime(){
if (!document.images)
return
if (CoffeeParse==1)
window.location.reload()
else{
CoffeeParse-=1
currentminutes=Math.floor(CoffeeParse/60)
currentsec=CoffeeParse%60
if (currentminutes!=0)
currenttime=currentminutes+" minutes and "+currentsec+" seconds until page refresh!"
else
currenttime=currentsec+" seconds left until page refresh!"
window.status=currenttime
setTimeout("refreshtime()",1000)
}
}

window.onload=refreshtime
//-->
</script>

مخفی کردن راست کلیک:
<SCRIPT LANGUAGE="JavaScript">
<!--

document.oncontextmenu = function(){return false}
if(document.layers) {
window.captureEvents(Event.MOUSEDOWN);
window.onmousedown = function(e){
if(e.target==document)return false;
}
}
else {
document.onmousedown = function(){return false}
}

// -->
</script>

برای صفحه خود راست کلیک سفارشی بسازید!!!!!!!!!!!!
<style>
<!--
.skin0 {
position:absolute;
text-align:left;
width:200px;
border:2px solid black;
background-color:menu;
font-family:Verdana;
line-height:20px;
cursor:default;
visibility:hidden;
}
.skin1 {
cursor:default;
font:menutext;
position:absolute;
text-align:left;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
width:120px;
background-color:menu;
border:1 solid buttonface;
visibility:hidden;
border:2 outset buttonhighlight;
}
.menuitems {
padding-left:15px;
padding-right:10px;
}
-->
</style>

<SCRIPT LANGUAGE="JavaScript1.2">
<!-- Web Site: http://www.dynamicdrive.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var menuskin = "skin1"; // skin0, or skin1
var display_url = 0; // Show URLs in status bar?
function showmenuie5() {
var rightedge = document.body.clientWidth-event.clientX;
var bottomedge = document.body.clientHeight-event.clientY;
if (rightedge < ie5menu.offsetWidth)
ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
else
ie5menu.style.left = document.body.scrollLeft + event.clientX;
if (bottomedge < ie5menu.offsetHeight)
ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
else
ie5menu.style.top = document.body.scrollTop + event.clientY;
ie5menu.style.visibility = "visible";
return false;
}
function hidemenuie5() {
ie5menu.style.visibility = "hidden";
}
function highlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "highlight";
event.srcElement.style.color = "white";
if (display_url)
window.status = event.srcElement.url;
}
}
function lowlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "";
event.srcElement.style.color = "black";
window.status = "";
}
}
function jumptoie5() {
if (event.srcElement.className == "menuitems") {
if (event.srcElement.getAttribute("target") != null)
window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
else
window.location = event.srcElement.url;
}
}
// End -->
</script>

<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();">
<div class="menuitems" url="javascript:history.back();">Go Back</div>
<div class="menuitems" url="http://freejava.i8.com">Go Home</div>
<hr>
<div class="menuitems" url="http://freejava.i8.com">JS Forum</div>
<div class="menuitems" url="http://freejava.i8.com">Site FAQs</div>
<hr>
<div class="menuitems" url="http://freejava.i8..com/link-us.html">Link to Us</div>
<div class="menuitems" url="http://freejava.i8.com/feedback.html">Contact Us</div>
</div>
<script language="JavaScript1.2">
if (document.all && window.print) {
ie5menu.className = menuskin;
document.oncontextmenu = showmenuie5;
document.body.onclick = hidemenuie5;
}
</script>


ست کردن homepage:
<![if IE]>
<a class="chlnk" style="cursor:hand;font-weight:bold;color:#004080;font-family:Verdana"HREF onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.freejava.i8.com');">Make echessdesign your Home Page!</a>


افکت زیبا در هنگام لود شدن صفحه:
<style>
<!--
.curtain{
position:absolute;
left:0;
top:0;
layer-background-color:800080;
background-color:800080;
border:0.1px solid PURPLE
}
-->
</style>


<div id="c1" class="curtain"></div><div id="c2" class="curtain"></div>
<script language="JavaScript1.2">


var speed=20
var temp=new Array()
var temp2=new Array()
if (document.layers){
for (c=1;c<=2;c++){
temp[c]=eval("document.c"+c+".clip")
temp2[c]=eval("document.c"+c)
temp[c].width=window.innerWidth
temp[c].height=window.innerHeight/2
temp2[c].top=(c-1)*temp[c].height
}
}
else if (document.all){
var curtainbottom=document.body.offsetHeight/2,curtaintop=0
for (c=1;c<=2;c++){
temp[c]=eval("document.all.c"+c+".style")
temp[c].width=document.body.clientWidth
temp[c].height=document.body.offsetHeight/2
temp[c].top=(c-1)*parseInt(temp[c].height)
}
}

function openit(){
window.scrollTo(0,0)
if (document.layers){
temp[1].bottom-=speed
temp[2].top+=speed
if (temp[1].bottom<=0)
clearInterval(stopit)
}
else if (document.all){
curtainbottom-=speed
temp[1].clip="rect(0 auto+"+curtainbottom+" 0)"
curtaintop+=speed
temp[2].clip="rect("+curtaintop+" auto auto)"
if (curtainbottom<=0)
clearInterval(stopit)
}
}
function gogo(){
stopit=setInterval("openit()",100)
}
gogo()

</script>


نشان دادن اطلاعات هارد دیسک بازدید کننده:
<div align="center">
<form action="file:///c|/"><input type="submit" value="c:\ drive"></form>
<p>
<form action="file:///a|/"><input type="submit" value="a:\ drive"></form>
<p>
<form action="file:///b|/"><input type="submit" value="b:\ drive"></form>
<p>
<form action="file:///d|/"><input type="submit" value="d:\ drive"></form>
<p>
<form action="file:///e|/"><input type="submit" value="e:\ drive"></form>
</div>


لرزش صفحه هنگام لود شدن:
<script>
<!--
//
var mx=5
var my=5

function movewindow(){
if (self.screenLeft + document.body.clientWidth > screen.width) mx=-5
if (self.screenLeft < 0) mx=5
if (self.screenTop + document.body.clientHeight> screen.Height - 20) my=-5
if (self.screenTop < 0) my=5
window.moveBy(mx, my)
setTimeout("movewindow()",100)
// movewindow()
}

-->
</script>
<BODY onload="movewindow();">

بک گراندی سایت خود را در هر رزولیشنی ثابت کنید:
<style>
<!--
#wrapper{
position:relative;
height:30px
}

#wrapper2{
position:absolute
}

#coffeemenu03{
filter:revealTrans(Duration=1.5,Transition=12)
visibility:hide
}


-->
</style></HEAD>

<BODY>

<ilayer id="coffeemenu01" height=35px>
<layer id="coffeemenu02" visibility=show>
<span id="wrapper">
<span id="wrapper2" onClick="dropit2();event.cancelBubble=true;return false">
<font face="Verdana"><b><a href="notthisbrowser.html">Click Here To Navigate</a></b></font>
</span>
</span>
</layer>
</ilayer>

<script language="JavaScript1.2">


var enableeffect=true

var selection=new Array()
selection[0]='<font face="ARIAL BLACK"><a href="http://www.coffeecup.com">Order Our Stuff</a><br>'
selection[1]='<a href="http://www.coffeecup.com">Contact Us via E-mail</a><br>'
selection[2]='<a href="http://www.coffeecup.com">Help With Our Items</a><br>'
selection[3]='<a href="http://www.coffeecup.com">Products We Have</a><br>'
selection[4]='<a href="http://www.coffeecup.com">Services We Offer</a><br></font>'

if (document.layers)
document.coffeemenu01.document.coffeemenu02.visibility='show'

function dropit2(){
if (document.all){
coffeemenu03.style.left=document.body.scrollLeft+event.clientX-event.offsetX
coffeemenu03.style.top=document.body.scrollTop+event.clientY-event.offsetY+18
if (coffeemenu03.style.visibility=="hidden"){
if (enableeffect)
coffeemenu03.filters.revealTrans.apply()
coffeemenu03.style.visibility="visible"
if (enableeffect)
coffeemenu03.filters.revealTrans.play()
}
else{
hidemenu()
}
}
}

function dropit(e){
if (document.coffeemenu03.visibility=="hide")
document.coffeemenu03.visibility="show"
else
document.coffeemenu03.visibility="hide"
document.coffeemenu03.left=e.pageX-e.layerX
document.coffeemenu03.top=e.pageY-e.layerY+19
return false
}

function hidemenu(){
if (enableeffect)
coffeemenu03.filters.revealTrans.stop()
coffeemenu03.style.visibility="hidden"
}

function hidemenu2(){
document.coffeemenu03.visibility="hide"
}

if (document.layers){
document.coffeemenu01.document.coffeemenu02.captureEvents(Event.CLICK)
document.coffeemenu01.document.coffeemenu02.onclick=dropit
}
else if (document.all)
document.body.onclick=hidemenu

</script>

<div id="coffeemenu03" style="position:absolute;left:0;top:0;layer-background-color:#C0C0C0;background-color:#C0C0C0;width:200;visibility:hidden;border:2px solid black;padding:0px">
<script language="JavaScript1.2">
if (document.all)
coffeemenu03.style.padding='4px'
for (i=0;i<selection.length;i++)
document.write(selection)
</script>
</div>

<script language="JavaScript1.2">
if (document.layers){
document.coffeemenu03.captureEvents(Event.CLICK)
document.coffeemenu03.onclick=hidemenu2
}
</script>


لود شدن صفحه خود را در حالت full screen به کار بر نشان دهید:
<script>
<!--


function fullwin(targeturl){
window.open(targeturl,"","fullscreen,scrollbars")
}
//-->
</script>

<form>
<input type="button" onClick="fullwin('http://www.freejava.i8.com')" value="Open window">
</form>


صفحه خود را به صورت اتوماتیک هنگام لود شدن ماکسیمایز کنید:
<script language="JavaScript1.2">
<!--

top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}

//-->
</script>


بانک کامل وجدید جاوا اسکریپت:
http://javascript.echessdesign.com
 
  • Like
Reactions: Mds

جدیدترین ارسال ها

بالا