NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Need help with Java (image floating)

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 05-17-2008, 02:50 AM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Feb 2005
Posts: 579
abcde is a jewel in the roughabcde is a jewel in the roughabcde is a jewel in the rough
 



Need help with Java (image floating)


I have this java code helps to floating images on the right and left of a web site. It works fine with IE, but on FF... it does not work.

here it is:
Code:
//////////////////////////////////////////////////////////////////
///              BEGIN
//////////////////////////////////////////////////////////////////

// set the width of the ad banner
var bannerleft_w = 0;
var bannerrite_w = 0;

var FloatBanner = new Array();

if (typeof(PageHost) == 'undefined')
{
	var PageHost = '';
}

FloatBanner[0]= new Array('http://mydomain.com/spacer.gif','#','1');
FloatBanner[1]= new Array('http://mydomain.com/image.gif','http://www.anotherdomain.com','2');


	window.onresize=ShowAdDiv;
	
	function FloatTopDiv()
	{
/////////////////////////////////////////////////////////////
///              Initial X and Y position of the banners !
/////////////////////////////////////////////////////////////
		startLX = ((document.body.clientWidth -780)/2) - 110 , startLY = 0;
		startRX = ((document.body.clientWidth)/2) + 398 , startRY = 0;

		var d = document;
		function ml(id)
		{
			var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			el.sP=function(x,y){this.style.left=x;this.style.top=y;};
			el.x = startRX;
			el.y = startRY;
			return el;
		}
		function m2(id)
		{
			var e2=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			e2.sP=function(x,y){this.style.left=x;this.style.top=y;};
			e2.x = startLX;
			e2.y = startLY;
			return e2;
		}
		window.stayTopLeft=function()
		{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY =  document.documentElement.scrollTop;
			else if (document.body)
				var pY =  document.body.scrollTop;
			if (document.body.scrollTop > 30){startLY = 3;startRY = 3;} else {startLY = 0;startRY = 0;};
			ftlObj.y += (pY+startRY-ftlObj.y)/16;
			ftlObj.sP(ftlObj.x, ftlObj.y);
			ftlObj2.y += (pY+startLY-ftlObj2.y)/16;
			ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			setTimeout("stayTopLeft()", 1);
		}
		ftlObj = ml("divAdRight");
		ftlObj2 = m2("divAdLeft");
		stayTopLeft();
	}
	
	function ShowAdDiv()
	{
		var objAdDivRight = document.getElementById("divAdRight");
		var objAdDivLeft = document.getElementById("divAdLeft");		
		
		if (document.body.clientWidth < 980)
		{
		    objAdDivRight.style.display = "none";
			objAdDivLeft.style.display = "none";
		}
		else
		{
			objAdDivRight.style.display = "block";
			objAdDivLeft.style.display = "block";
			FloatTopDiv();
		}
	}
	

function DisplayFloatBanner(side)
{
	document.write('<table cellspacing=0 cellpadding=0 border=0 width='+bannerleft_w+' >')
	
	if (side==1) // on left
		for (i=0; i<FloatBanner.length; i++){
			if(FloatBanner[i][2]=='1'){						
				document.write('<tr><td><a target="_blank" href="'+FloatBanner[i][1]+'"><img src="'+FloatBanner[i][0]+'" width='+bannerleft_w+' border=0></a>');
				document.write('<tr><td><object width="100" height="200"><param name="movie" value="http://www.mydomain.com/ads/yan_25-2.swf"><param name="quality" value="high"><embed src="http://www.mydomain.com/ads/yan_25-2.swf" quality="high" width="100" height="200"></embed></object></br></td></tr>');
			}
		}
				
					
	if (side==2) // on right
		for (i=0; i<FloatBanner.length; i++){
			if(FloatBanner[i][2]=='2'){
				document.write('<tr><td><a target="_blank" href="'+FloatBanner[i][1]+'"><img src="'+FloatBanner[i][0]+'" width="100" height="200" border=0></a><br></td></tr>');
				//document.write('<tr><td><object width="100" height="200"><param name="movie" value="http://data.mydomain.com/data/adv/fullsize/liveshow_tramy2_247.swf"><param name="quality" value="high"><embed src="http://data.mydoamin.com/data/adv/fullsize/liveshow_tramy2_247.swf" quality="high" width="100" height="200"></embed></object>'); 
			}
		}

	document.write('</table>');
}

//////////////////////////////////////////////////////////////////
///              END
//////////////////////////////////////////////////////////////////

????: NamePros.com http://www.namepros.com/programming/470332-need-help-with-java-image-floating.html
????: NamePros.com http://www.namepros.com/showthread.php?t=470332
Code:
<DIV id=divAdRight style="DISPLAY: none; POSITION: absolute; TOP: 0px"> <script language="JavaScript">DisplayFloatBanner(2);</script> </DIV>
<DIV id=divAdLeft style="DISPLAY: none; POSITION: absolute; TOP: 0px"> <script language="JavaScript">DisplayFloatBanner(1);</script> </DIV>
<SCRIPT language=JavaScript>ShowAdDiv();</SCRIPT>

Thanks
abcde is offline  
Old 05-22-2008, 05:07 PM   #2 (permalink)
NamePros Regular
 
Turco's Avatar
Join Date: Aug 2007
Location: Ankara, Turkey
Posts: 370
Turco is on a distinguished road
 



Hi, I hope I don't offend you by these words, but this is not Java. This is JavaScript.
Java doesn't have "var" type definition, and isn't used like this.

I hope someone can help you because I am not good at Javascript.
Turco is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:14 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger