Advertisement

04.11.2008 at 02:40AM PDT, ID: 23314521
[x]
Attachment Details

Help with Javascript to move a span to left and top position for Firefox

Asked by gbzhhu in JavaScript, Miscellaneous Web Development, Dynamic HTML (DHTML)

Hi,

I had code that worked well in IE and now I am trying to get it to work in Firefox but I don't know Javascript well at all.  The code below is a function that shows a span that was already hidden and set its left and top positions.  Currently the only problem is that top is too hight up and the left is way too far to the right.

Help much appreciated

Cheers
H

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
//The code calling the function is here
<map name="testMap">
   <area onMouseover="showByLink('img3','nameLayer',this,-500,30)" onMouseout="hide('nameLayer')" shape="circle" coords="282,326,4"/>
</map>
 
//The function is here
<SCRIPT LANGUAGE="JavaScript"><![CDATA[
	function showByLink(imgName, object,link,x,y) {	
		img=eval(imgName);
		document.county.src= img.src;
 
//Added this for Firefox but not working
		var browser = window.navigator.userAgent
		if(browser.indexOf("Firefox") > 0) {
			var c = document.getElementsByTagName("body")[0].getElementsByTagName("*");
		
			if(c){	
				c[object].style.visibility = 'visible';
				if (c[object].myFlag == null) {					
					c[object].style.left = link.x + x;
					c[object].style.top = c[object].offsetTop + y;
				}
				c[object].myFlag = true;
			}
		}
		else{							
			if (document.layers && document.layers[object]) {
				document.layers[object].left = link.x + x;
				document.layers[object].top = link.y + y;
				document.layers[object].visibility = 'visible';
			}
			else if (document.all) {
				document.all[object].style.visibility = 'visible';
 
				if (document.all[object].myFlag == null) {
					document.all[object].style.posLeft = document.all[object].offsetLeft + x;
					document.all[object].style.posTop = document.all[object].offsetTop + y;
				}
				document.all[object].myFlag = true;
			}
		}
	}
[+][-]04.11.2008 at 08:59AM PDT, ID: 21335472

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 11:11PM PDT, ID: 21356276

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: JavaScript, Miscellaneous Web Development, Dynamic HTML (DHTML)
Sign Up Now!
Solution Provided By: GreenGhost
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.15.2008 at 02:15AM PDT, ID: 21357078

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628