Kirjautuminen

Haku

Tehtävät

Keskustelu: Nettisivujen teko: Seuraava valikko

thekoodaaja [24.11.2004 20:02:42]

#

Minä löysin tälläisen Js scruptin miten sitä pystyisi käyttää? En ole saanut toimimaan. Sen pitäisi toimia.

/<script>
function chaserRollover(imgid,imgsrc)
{
	nnstr=(document.layers)?"document.layers.CC.":""
	eval(nnstr+"document.images['"+imgid+"'].src='"+imgsrc+"'")
}


function ClassChaser(divName, objName,takeOffTop, takeOffBottom)
{
	// note the object is assuming that the magins of the HTML page are set to 0
	//Properties
	this.objName=objName
	this.name=divName
	this.takeOffTop=(takeOffTop!=null)?parseInt(takeOffTop):0;			//default value to 0
	this.takeOffBottom=(takeOffBottom!=null)?parseInt(takeOffBottom):0;	//default value to 0
	this.startPos												//position where the div start chasing from
	this.endPos													//position where the div end chasing in
	this.styleRef												//refers to div styles according to browsers
	this.divObj													//div object reference
	this.availableScrollingHeight								//available height for the div to scroll in
	this.divHeight												//chaserHeight
	this.callRate = 10
	this.slideTime = 1200
	this.A
	this.B
	this.C
	this.D
	this.interval
	this.initialised


	//methods
	this.init = m_sw_init;
	this.findObj = m_sw_findObj;
	this.main =	m_sw_main;
	this.slide = m_sw_slide;
	this.slideInit = m_sw_slideInit;
	this.startChase = m_sw_startChase;
}
function m_sw_init()
{
	this.macstr='MacPPC'
	this.ismac = (navigator.platform == this.macstr)
	//alert('hello');
	this.styleRef=(document.layers)?"":".style"
	this.divObj=this.findObj(this.name)
	//position layer
	eval("this.divObj"+this.styleRef+".top=this.takeOffTop")
	this.divHeight=(document.layers)?parseInt(this.divObj.document.height):((document.all)?parseInt(this.divObj.clientHeight):parseInt(this.divObj.offsetHeight))
	this.availableScrollingHeight=((document.all)?((this.ismac)?parseInt(document.body.offsetHeight):parseInt(document.body.scrollHeight)):parseInt(document.height))-this.takeOffTop-this.takeOffBottom-this.divHeight
	this.startPos=this.takeOffTop
	this.endPos=this.availableScrollingHeight+this.takeOffTop;
	this.initialised=true
	if (!document.all)
	{
		eval("this.interval=setInterval(\'"+this.objName+".main()\',this.callRate)");//this.callRate
	}
}

function m_sw_findObj(n,d) {
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
	    	d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	//Case IE
	if(!(x=d[n])&&d.all)
		x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
	//Case NN
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=this.findObj(n,d.layers[i].document);
	//Case NN6
	if(!x && d.getElementById)
		x=d.getElementById(n);
	return x;
}

function m_sw_main()
{
	eval("this.currentY=parseInt(this.divObj"+this.styleRef+".top)")
	this.scrollTop	= (document.all)?parseInt(document.body.scrollTop):parseInt(window.pageYOffset);
	var newTargetY	= this.scrollTop +(this.startPos)

	if ( this.currentY != newTargetY ) {

		if ( newTargetY != this.targetY ) {

			this.targetY = newTargetY
			if (this.availableScrollingHeight>0)
				this.slideInit( )

		}
	if (this.availableScrollingHeight>0)
		this.slide( )

	}
}

function m_sw_slideInit()
{
	var now	= new Date( )
	this.A		= this.targetY - this.currentY
	this.B		= Math.PI / ( 2 * this.slideTime )
	this.C		= now.getTime( )

	if (Math.abs(this.A) > this.availableScrollingHeight) {
		this.D = this.A > 0 ? this.targetY - this.availableScrollingHeight : this.targetY + this.availableScrollingHeight
		this.A = this.A > 0 ? this.availableScrollingHeight : -this.availableScrollingHeight
	} else {
		this.D = this.currentY
	}
}




function m_sw_slide()
{
	var now	= new Date( )
	var newY	= this.A * Math.sin( this.B * ( now.getTime( ) - this.C ) ) + this.D
	newY		= Math.round( newY )

	if (( (this.A > 0) && (newY > this.currentY) && (newY<=this.endPos)) ||
		( (this.A < 0) && (newY < this.currentY) && (newY<=this.endPos) )) {
			eval("this.divObj"+this.styleRef+".top=newY")
	}
	if ((newY==this.targetY)&& (this.interval)&&(document.all))
	{
		clearInterval(this.interval)
	}
}

function m_sw_startChase()
{
	if ((document.all)&&(this.initialised))
	{
		if (this.interval)
		{
			clearInterval(this.interval)
		}
		eval("this.interval=setInterval(\'"+this.objName+".main()\',this.callRate)");
	}
}

function SurfTo(PageLocation) {
	window.location.href = PageLocation;
}

Mukana tuli myös tälläinen

//window.onunload=launchQuestionnaire
	function launchQuestionnaire()
	{
		window.open('http://' + window.location.host + '/questionnaire/webexperience.asp','questionnaire','height=470,width=550,scrollbars=1');
		self.focus();
	}


	function validEmail(address) {
		var invalids = " /:,;";

		if (address == "")
			return false;

		for (i=0; i<invalids.length; i++) {
			badChar = invalids.charAt(i)
			if (address.indexOf(badChar,0)>1) {
				return false;
			}
		}

		atPos = address.indexOf("@",1)
		if (atPos == -1)
			return false;

		if (address.indexOf("@",atPos+1) != -1)
			return false;

		periodPos = address.indexOf(".",atPos)
		if (periodPos == -1)
			return false;

		if (periodPos+3 > address.length)
			return false;

		return true;
	}

sqwiik [24.11.2004 20:21:09]

#

TUSKA ja KÄRSIMYS osaksesi putkan layoutin roilaamisesta...

On yleensä hyödytöntä iskeä jotain koodia tänne ja ilmoittaa jotta tässä koodi, missä virhe?

Eli: mitä tuon pitäisi tehdä, mitä se ei tee, ja miten sen toiminta on virheellinen?

Ja herran tähden laita sinne rivinvaihtoja... Layout on piloilla X(

joekool [25.11.2004 01:03:52]

#

heheh, ja eikun kaikki vain perehtymään :)

Blaze [25.11.2004 07:12:33]

#

Voin perehtyä koodiin 30 eurolla/tunti, minimivelotus yks tunti :)

samii [25.11.2004 10:00:30]

#

Viideskymmenesseitsämäs rivi, kahdeskymmenesneljäs kirjain. Mietippä laskinko välit / tyhjät rivit ;)

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta