java script

samane_r

Member
سلام به همه
من صفحه وبي طراحي كرده ام كه مي خواهم در آن از دو كد جاوا اسكريپت استفاده كنم ولي هر دو را همزمان نمي توانم استفاده كنم به محض اينكه كد جاواي دوم را وارد ميكنم اولي از كار مي افتد .چه كنم :?: :roll:
 

saman_sweden

Active Member
samane_r گفت:
سلام به همه
من صفحه وبي طراحي كرده ام كه مي خواهم در آن از دو كد جاوا اسكريپت استفاده كنم ولي هر دو را همزمان نمي توانم استفاده كنم به محض اينكه كد جاواي دوم را وارد ميكنم اولي از كار مي افتد .چه كنم :?: :roll:
مگه ميشه
10 تا جاوا اسكريپت هم تو يه صفحه داشته باشيد ميتونيد همزمان بكار اندازيد
بيشتر توضيح بده يا كد توبنويس درستش كنم
 

samane_r

Member
جاوا اسكريپت اول من يك منو و دومي يك ساعت مي باشد ولي اين دو همزمان نمي توانند در صفحه نشان داده شوند
 
سلام
دوست عزيز تا شما كدها را اينجا نذاري كه بقيه ببينند كسي نميتونه كمتون كنه چون كه معلوم نيست مشكل كجاست!
 

Scorpio

Member
Persianservers گفت:
سلام
دوست عزيز تا شما كدها را اينجا نذاري كه بقيه ببينند كسي نميتونه كمتون كنه چون كه معلوم نيست مشكل كجاست!

دوست عزيز منظورت از اين حرف چيه ؟!!

علي
 

saman_sweden

Active Member
samane_r گفت:
جاوا اسكريپت اول من يك منو و دومي يك ساعت مي باشد ولي اين دو همزمان نمي توانند در صفحه نشان داده شوند

شما نخواستيد كدتون را بنويسيد تا من مشكلتون را حل كنم

اميدوارم اين كد بدردتون بخوره و بيشتر از پاسخ نخواهم داد
در اين كد ساعت تاريخ و منو همه باهم است
کد:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


<style>
<!--
#slidemenubar, #slidemenubar2{
position:absolute;
border:1.5px solid black;
background-color:#F2F2F2;
layer-background-color:#F2F2F2;
font:bold 12px Verdana;
line-height:20px;
}
-->
</style>
</head>

<body>
<CENTER>
<SCRIPT LANGUAGE="JavaScript">



<!-- Begin
Stamp = new Date();
document.write('<font size="2" face="Arial"><B>' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getYear() + '</B></font><BR>');
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " P.M.";
}
else {
Time = " A.M.";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}	
document.write('<font size="2" face="Arial"><B>' + Hours + ":" + Mins + Time + '</B></font>');
// End -->
</SCRIPT>
</CENTER>

<script language="JavaScript1.2">
var slidemenu_width=100 //specify width of menu (in pixels)
var slidemenu_reveal=15 //specify amount that menu should protrude initially
var slidemenu_top=170 //specify vertical offset of menu on page
var slidemenu_left=170
var ns4=document.layers?1:0
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all?1:0

if (ie4||ns6)
document.write('<div id="slidemenubar2" style="left:'+((slidemenu_width-slidemenu_reveal)*-1)+'; top:'+slidemenu_top+'; width:'+slidemenu_width+'" onMouseover="pull()" onMouseout="draw()">')
else if (ns4){
document.write('<style>\n#slidemenubar{\nwidth:'+slidemenu_width+';}\n<\/style>\n')
document.write('<layer id="slidemenubar" left='+slidemenu_lef+' top='+slidemenu_top+' width='+slidemenu_width+' onMouseover="pull()" onMouseout="draw()" visibility=hide>')
}

var sitems=new Array()

sitems[0]=["<big><font face='Arial'>سامان منو</font></big>", ""]
sitems[1]=["		لينک اول 		", "/"]
sitems[2]=["		لبنک دوم  		", "/"]
sitems[3]=["		لينک سوم 		", "/"]
sitems[4]=["		لينک چهارم 		", "/"]


var target=""

if (ie4||ns4||ns6){
for (i=0;i<sitems.length;i++){
if (sitems[i][1])
document.write('<a href="'+sitems[i][1]+'" target="'+target+'">')
document.write(sitems[i][0])
if (sitems[i][1])
document.write('</a>')
document.write('<br>\n')
}
}

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (ns4){
document.slidemenubar.left=((slidemenu_width-slidemenu_reveal)*-1)
document.slidemenubar.visibility="show"
setTimeout("window.onresize=regenerate",400)
}
}
window.onload=regenerate2
rightboundary=0
leftboundary=(slidemenu_width-slidemenu_reveal)*-1
if (ie4||ns6){
document.write('</div>')
themenu=(ns6)? document.getElementById("slidemenubar2").style : document.all.slidemenubar2.style
}
else if (ns4){
document.write('</layer>')
themenu=document.layers.slidemenubar
}

function pull(){
if (window.drawit)
clearInterval(drawit)
pullit=setInterval("pullengine()",10)
}
function draw(){
clearInterval(pullit)
drawit=setInterval("drawengine()",10)
}
function pullengine(){
if ((ie4||ns6)&&parseInt(themenu.left)<rightboundary)
themenu.left=parseInt(themenu.left)+30
else if(ns4&&themenu.left<rightboundary)
themenu.left+=10
else if (window.pullit){
themenu.left=0
clearInterval(pullit)
}
}

function drawengine(){
if ((ie4||ns6)&&parseInt(themenu.left)>leftboundary)
themenu.left=parseInt(themenu.left)-10
else if(ns4&&themenu.left>leftboundary)
themenu.left-=30
else if (window.drawit){
themenu.left=leftboundary
clearInterval(drawit)
}
}
</script>
<BR><center>
  <a href='http://www.swedenet.net'>swedenet</a> 
</center> 
</body>
</html>
 

mrezaf

Member
با سلام
آقاي سامان بنده از كدهاي شما خيلي خوشم آمد. هر چند ادبيات بعضي از دوستان زياد جالب نبود.
باز هم از سامان متشكرم
 

samane_r

Member
سلام آقا سامان
من دو كدي را كه با هم نمي تونم توي يك صفحه به كار ببرم براتون ارسال مي كنم
لطفا اگر به نتيجه اي رسيديد به من هم اطلاع دهيد
کد:
<HTML>
<HEAD><TITLE>Free Scripts And Tools For Webmasters</TITLE>
</HEAD>
<BODY>
<style>
body{background-color:#FFFFFF}
A{color:Navy; text-decoration:none; font-size:8pt}
A:hover{color:red; font-size:8pt}
A:visited:{color:#808080}
TD{font-family:arial,helvetica; font-size:10pt}
DIV.clTopMenu{position:absolute; width:101; height:150; clip:rect(0,101,14,0); visibility:hidden; z-index:31; 

layer-background-color:#EEEEEE; background-color:#EEEEEE}
DIV.clTopMenuBottom{position:absolute; width:101; height:3; clip:rect(0,101,3,0); top:11; layer-background-color:#CECFCE; 

background-color:#CECFCE; z-index:2}
DIV.clTopMenuText{position:absolute; width:91; left:5; top:15; font-family:arial,helvetica; font-size:11px; 

background-color:#EEEEEE; z-index:1} 
</style>
<script>
ie=document.all?1:0
n=document.layers?1:0

// If you want to change the appearens on the text, background-colors, size or
//anything do that in the style tag above.

//Variables to set.

//How many menus do you have? (remember to copy and add divs in the body if you add menus)
var numberOfMenus=2
//The width on the menus (set the width in the stylesheet as well)
var mwidth=101
//Pixels between the menus
var pxBetween=10
//The first menus left position
var fromLeft=10
//The top position of the menus
var fromTop=50
//The bgColor of the bottom mouseover div
var bgColor='#CECFCE'
//The bgColor to change to
var bgColorChangeTo='#6380BC'
//The position the mouseover line div will stop at when going up!
var imageHeight=11
/***************************************************************************
You shouldn't have to change anything below this
****************************************************************************/
//Object constructor
function makeNewsMenu(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'					
	this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')	
	this.scrollHeight=n?this.css.document.height:eval('document.all.'+obj+'.offsetHeight')
	this.moveIt=b_moveIt;this.bgChange=b_bgChange;
	this.slideUp=b_slideUp; this.slideDown=b_slideDown;
	this.clipTo=b_clipTo;
    this.obj = obj + "Object"; 	eval(this.obj + "=this")		
}
//Objects methods
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}
function b_bgChange(color){if(ie) this.css.backgroundColor=color; else this.css.bgColor=color}
function b_clipTo(t,r,b,l){
	if(n){this.css.clip.top=t; this.css.clip.right=r; this.css.clip.bottom=b; this.css.clip.left=l
	}else this.css.clip="rect("+t+","+r+","+b+","+l+")";
}
function b_slideUp(ystop,moveby,speed,fn,wh){
	if(!this.slideactive){
		if(this.y>ystop){
			this.moveIt(this.x,this.y-5); eval(wh)
			setTimeout(this.obj+".slideUp("+ystop+","+moveby+","+speed+",'"+fn+"','"+wh+"')",speed)
		}else{
			this.slideactive=false; this.moveIt(0,ystop); eval(fn)
		}
	}
}
function b_slideDown(ystop,moveby,speed,fn,wh){
	if(!this.slideactive){
		if(this.y<ystop){
			this.moveIt(this.x,this.y+5); eval(wh)
			setTimeout(this.obj+".slideDown("+ystop+","+moveby+","+speed+",'"+fn+"','"+wh+"')",speed)
		}else{
			this.slideactive=false; this.moveIt(0,ystop); eval(fn)
		}
	}
}
//Initiating the page, making cross-browser objects
function newsMenuInit(){
	oTopMenu=new Array()
	for(i=0;i<=numberOfMenus;i++){
		oTopMenu[i]=new Array()
		oTopMenu[i][0]=new makeNewsMenu('divTopMenu'+i)
		oTopMenu[i][1]=new makeNewsMenu('divTopMenuBottom'+i,'divTopMenu'+i)
		oTopMenu[i][2]=new makeNewsMenu('divTopMenuText'+i,'divTopMenu'+i)
		oTopMenu[i][1].moveIt(0,imageHeight)
		oTopMenu[i][0].clipTo(0,mwidth,imageHeight+3,0)
		oTopMenu[i][0].moveIt(i*mwidth+fromLeft+(i*pxBetween),fromTop)
		oTopMenu[i][0].css.visibility="visible"
	}
}
//Moves the menu
function topMenu(num){
	if(oTopMenu[num][1].y==imageHeight) 

oTopMenu[num][1].slideDown(oTopMenu[num][2].scrollHeight+20,10,40,'oTopMenu['+num+'][0].clipTo(0,mwidth,oTopMenu['+num+'][1].

y+3,0)','oTopMenu['+num+'][0].clipTo(0,mwidth,oTopMenu['+num+'][1].y+3,0)')
	else if(oTopMenu[num][1].y==oTopMenu[num][2].scrollHeight+20) 

oTopMenu[num][1].slideUp(imageHeight,10,40,'oTopMenu['+num+'][0].clipTo(0,mwidth,oTopMenu['+num+'][1].y+3,0)','oTopMenu['+num

+'][0].clipTo(0,mwidth,oTopMenu['+num+'][1].y+3,0)')
}
//Changes background onmouseover
function menuOver(num){oTopMenu[num][1].bgChange(bgColorChangeTo)}
function menuOut(num){oTopMenu[num][1].bgChange(bgColor)}


//Calls the init function onload
onload=newsMenuInit;
</script>

<!-- Remember the "news" "key control" and "page contols" text are images, you probably want to change those
with your own images. If your own images have different sizes please adjust the height and clips
of the divs, and change the imageHeight variable in the script. Good luck -->
<div id="divTopMenu0" class="clTopMenu"><a href="#" onmouseover="menuOver(0)" onmouseout="menuOut(0)" onclick="topMenu(0); 

if(ie)this.blur(); return false"><img src="news.gif" width=101 height=11 alt="" border=0 align="top"></a>
	<div id="divTopMenuText0" class="clTopMenuText">
		Added some link to this menu<br><br>
		<A HREF="http://www.AceJS.com">AceJS.com</a><BR>
		Remember to join our newsletter!
	</div>
	<div id="divTopMenuBottom0" class="clTopMenuBottom"></div>
</div>

<div id="divTopMenu1" class="clTopMenu"><a href="#" onmouseover="menuOver(1)" onmouseout="menuOut(1)" onclick="topMenu(1); 

if(ie)this.blur(); return false"><img src="keycontrol.gif" width=101 height=11 alt="" border=0 align="top"></a>
	<div id="divTopMenuText1" class="clTopMenuText">
		You can change the above images to suit you menu.
		<BR><BR>
		You an use images (icons) in these menus.<BR>
		Check out our <BR><A HREF="http://www.AceJS.com/icons.html">Icons Page</A>
	</div>
	<div id="divTopMenuBottom1" class="clTopMenuBottom"></div>
</div>
<div id="divTopMenu2" class="clTopMenu"><a href="#" onmouseover="menuOver(2)" onmouseout="menuOut(2)" onclick="topMenu(2); 

if(ie)this.blur(); return false"><img src="pagecontrol.gif" width=101 height=11 alt="" border=0 align="top"></a>
	<div id="divTopMenuText2" class="clTopMenuText">
		This one is just like the other ones.<BR>
		Add some links to this menu and it will look much better!	
	</div>
	<div id="divTopMenuBottom2" class="clTopMenuBottom"></div>
</div>
<!-- To add a new menu just copy these lines:
<div id="divTopMenuN" class="clTopMenu"><a href="#" onmouseover="menuOver(N)" onmouseout="menuOut(N)" onclick="topMenu(N); 

if(ie)this.blur(); return false">HEADING IMAGE GOES HERE</a>
	<div id="divTopMenuTextN" class="clTopMenuText">
		TEXT HERE	
	</div>
	<div id="divTopMenuBottomN" class="clTopMenuBottom"></div>
</div>
And change the letter N to a number higher then the last menu...
(and remember to set the variable numberOfMenus in the script to 
the same number of menus you have (remember it starts counting
at 0) -->
<P>
<B><A HREF="http://www.AceJS.com">AceJS.com</A> The JavaScript Directory</B>
</BODY>
</HTML>


اين هم دوميش


کد:
<HTML>
<HEAD><TITLE>Free Scripts And Tools For Webmasters </TITLE>
</HEAD>
<BODY>
<FONT FACE="MS Sans serif,Tahoma,Helvetica" SIZE="2">
<SCRIPT LANGUAGE="JavaScript">
dCol='000000';//date colour.
fCol='000000';//face colour.
sCol='000000';//seconds colour.
mCol='000000';//minutes colour.
hCol='000000';//hours colour.
ClockHeight=40;
ClockWidth=40;
ClockFromMouseY=0;
ClockFromMouseX=100;

//Alter nothing below! Alignments will be lost!

d=new Array("SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY");
m=new Array("JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER");
date=new Date();
day=date.getDate();
year=date.getYear();
if (year < 2000) year=year+1900;
TodaysDate=" "+d[date.getDay()]+" "+day+" "+m[date.getMonth()]+" "+year;
D=TodaysDate.split('');
H='...';
H=H.split('');
M='....';
M=M.split('');
S='.....';
S=S.split('');
Face='1 2 3 4 5 6 7 8 9 10 11 12';
font='Arial';
size=1;
speed=0.6;
ns=(document.layers);
ie=(document.all);
Face=Face.split(' ');
n=Face.length;
a=size*10;
ymouse=0;
xmouse=0;
scrll=0;
props="<font face="+font+" size="+size+" color="+fCol+"><B>";
props2="<font face="+font+" size="+size+" color="+dCol+"><B>";
Split=360/n;
Dsplit=360/D.length;
HandHeight=ClockHeight/4.5
HandWidth=ClockWidth/4.5
HandY=-7;
HandX=-2.5;
scrll=0;
step=0.06;
currStep=0;
y=new Array();x=new Array();Y=new Array();X=new Array();
for (i=0; i < n; i++){y[i]=0;x[i]=0;Y[i]=0;X[i]=0}
Dy=new Array();Dx=new Array();DY=new Array();DX=new Array();
for (i=0; i < D.length; i++){Dy[i]=0;Dx[i]=0;DY[i]=0;DX[i]=0}
if (ns){
for (i=0; i < D.length; i++)
document.write('<layer name="nsDate'+i+'" top=0 left=0 height='+a+' 

width='+a+'><center>'+props2+D[i]+'</font></center></layer>');
for (i=0; i < n; i++)
document.write('<layer name="nsFace'+i+'" top=0 left=0 height='+a+' 

width='+a+'><center>'+props+Face[i]+'</font></center></layer>');
for (i=0; i < S.length; i++)
document.write('<layer name=nsSeconds'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 

color='+sCol+'><center><b>'+S[i]+'</b></center></font></layer>');
for (i=0; i < M.length; i++)
document.write('<layer name=nsMinutes'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 

color='+mCol+'><center><b>'+M[i]+'</b></center></font></layer>');
for (i=0; i < H.length; i++)
document.write('<layer name=nsHours'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 

color='+hCol+'><center><b>'+H[i]+'</b></center></font></layer>');
}
if (ie){
document.write('<div id="Od" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < D.length; i++)
document.write('<div id="ieDate" 

style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center">'+props2+D[i]+'</B></font></div>');
document.write('</div></div>');
document.write('<div id="Of" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < n; i++)
document.write('<div id="ieFace" 

style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center">'+props+Face[i]+'</B></font></div>');
document.write('</div></div>');
document.write('<div id="Oh" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < H.length; i++)
document.write('<div id="ieHours" 

style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+hCol+';text-align:center;font-weight

:bold">'+H[i]+'</div>');
document.write('</div></div>');
document.write('<div id="Om" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < M.length; i++)
document.write('<div id="ieMinutes" 

style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+mCol+';text-align:center;font-weight

:bold">'+M[i]+'</div>');
document.write('</div></div>')
document.write('<div id="Os" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < S.length; i++)
document.write('<div id="ieSeconds" 

style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+sCol+';text-align:center;font-weight

:bold">'+S[i]+'</div>');
document.write('</div></div>')
}
(ns)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt){
ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFromMouseY;
xmouse = (ns)?evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX;
}
(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
function ClockAndAssign(){
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins/30;
hr = time.getHours();
hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360;
if (ie){
Od.style.top=window.document.body.scrollTop;
Of.style.top=window.document.body.scrollTop;
Oh.style.top=window.document.body.scrollTop;
Om.style.top=window.document.body.scrollTop;
Os.style.top=window.document.body.scrollTop;
}
for (i=0; i < n; i++){
 var F=(ns)?document.layers['nsFace'+i]:ieFace[i].style;
 F.top=y[i] + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll;
 F.left=x[i] + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180);
 }
for (i=0; i < H.length; i++){
 var HL=(ns)?document.layers['nsHours'+i]:ieHours[i].style;
 HL.top=y[i]+HandY+(i*HandHeight)*Math.sin(hrs)+scrll;
 HL.left=x[i]+HandX+(i*HandWidth)*Math.cos(hrs);
 }
for (i=0; i < M.length; i++){
 var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes[i].style;
 ML.top=y[i]+HandY+(i*HandHeight)*Math.sin(min)+scrll;
 ML.left=x[i]+HandX+(i*HandWidth)*Math.cos(min);
 }
for (i=0; i < S.length; i++){
 var SL=(ns)?document.layers['nsSeconds'+i]:ieSeconds[i].style;
 SL.top=y[i]+HandY+(i*HandHeight)*Math.sin(sec)+scrll;
 SL.left=x[i]+HandX+(i*HandWidth)*Math.cos(sec);
 }
for (i=0; i < D.length; i++){
 var DL=(ns)?document.layers['nsDate'+i]:ieDate[i].style;
 DL.top=Dy[i] + ClockHeight*1.5*Math.sin(currStep+i*Dsplit*Math.PI/180)+scrll;
 DL.left=Dx[i] + ClockWidth*1.5*Math.cos(currStep+i*Dsplit*Math.PI/180);
 }
currStep-=step;
}
function Delay(){
scrll=(ns)?window.pageYOffset:0;
Dy[0]=Math.round(DY[0]+=((ymouse)-DY[0])*speed);
Dx[0]=Math.round(DX[0]+=((xmouse)-DX[0])*speed);
for (i=1; i < D.length; i++){
Dy[i]=Math.round(DY[i]+=(Dy[i-1]-DY[i])*speed);
Dx[i]=Math.round(DX[i]+=(Dx[i-1]-DX[i])*speed);
}
y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed);
x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed);
for (i=1; i < n; i++){
y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed);
x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed);
}
ClockAndAssign();
setTimeout('Delay()',20);
}
if (ns||ie)window.onload=Delay;
</SCRIPT>
<P>
<B><A HREF="http://www.AceJS.com">AceJS.com</A> The JavaScript Directory</B>
</BODY>
</HTML>
 

saman_sweden

Active Member
اون كدهايي كه دادي دربداغونه بهتره به همون سايت كه كدهارا گرفتيد مراجعه كرده و كد صحيح را دان لود كنيد

http://www.AceJS.com

اون كدها دستكاري شده است و من وقت تك بتك نگاه كردن كدها راندارم اينطوري وقت ميبره
اصل كد را نوشته و يا اينكه لينك مستقيم اون كد ها را بگداريد خودك نگاهش ميكنم و نتيجه را بهتون ميدم
 

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

بالا