Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Software Development
Tag Cloud
access acer asus batch bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
JavaScript: to add onMouseOver (clientside)

Reply  
Thread Tools
Mr Red's Avatar
Computer Specs
Member with 74 posts.
 
Join Date: Dec 2008
01-Dec-2008, 04:53 PM #1
JavaScript: to add onMouseOver (clientside)
Hi

I have been doing this for years on http://www.users.waitrose.com/~cresby/ses/sesc.htm

The call is added using JavaScript to speed loading (the dial-ups are still out there)

Recently I tried changing the function call to include a parameter and it failed. Am I trying the impossible?

I could code it in HTML (which seems to perversely work) and it would not be tiresome because my HTML is coded with VBA (as if by hand to reduce bulk and increase speed) but it does add bulk. There are a lot of links carrying Post Codes. The data are tabular and numerous.

However I try to keep the bulk down. The example page is a successful attempt to split the data in logical sections like day or location.

So can I code JavaScript to add calls with parameters or must I code in HTML?

Ideas welcome. TIA
Mr Red's Avatar
Computer Specs
Member with 74 posts.
 
Join Date: Dec 2008
02-Dec-2008, 09:28 AM #2
Perhaps I should add that the intention is to keep it compatible with as many browsers as possible so some JavaScript cannot be used.
I test on IE5.5, Mozilla 1.summit Opera 5 and FF2.

onMouseOver seems the only simple way to do it. I haven't yet found how to transfer the contents of the link (or Alt or Title) during an onMouseOver event if added in JavaScript. In HTML at compile time has worked.
-Fabez-'s Avatar
Senior Member with 1,943 posts.
 
Join Date: Jul 2008
Location: Earth
Experience: General
02-Dec-2008, 03:27 PM #3
So what exactly do you want your JavaScript code to do ?
Mr Red's Avatar
Computer Specs
Member with 74 posts.
 
Join Date: Dec 2008
02-Dec-2008, 04:54 PM #4
I was trying to replicate the Alt/Title pop-up but make it a tad more obvious.
I have code to keep the layer in one place regardless of scrolling.

The Alt/Title text is derived from the Hyperlink and gives location info that can be used on satnavs. Some surfers ask if I could add it. Obviously they don't look too closely and the Alt/Title pop-up times-out anyway.

Once it is obvious they will stop asking. The problem is to get the text transferred to the calling statement. This works in HTML but I was trying to keep the HTML short so that it loads quickly over dial-up (the lowest common denominator IMO)

Clientside makes it simple and cheap for me. IE5.5, Opera 5, FF 2 and Moczilla 1.0XXXX are used to verify it saitisfies the criterion of luddit audience.

Any method that can transfer the hyperlink (or Alt/Title as it is already parsed) in the calling statement will do the trick.
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
13-Dec-2008, 03:14 PM #5
Quote:
Originally Posted by Mr Red View Post
IE5.5, Opera 5, FF 2 and Moczilla 1.0XXXX are used to verify it saitisfies the criterion of luddit audience.
Woah, browser update time?

Opera 5 was released a full 8 years ago.

v10 should be coming out sometime soon.
-Fabez-'s Avatar
Senior Member with 1,943 posts.
 
Join Date: Jul 2008
Location: Earth
Experience: General
13-Dec-2008, 03:32 PM #6
Mmj has a good point, maybe you should ask your target audience to upgrade thier browsers.
JimmySeal's Avatar
Computer Specs
Member with 289 posts.
 
Join Date: Sep 2007
Experience: Getting there
25-Dec-2008, 01:30 PM #7
Your page is generating a JavaScript error because your JavaScript file is missing this code:

Code:
function makeCursorObj(obj,nest){ 
nest=(!nest) ? '':'document.'+nest+'.' 
this.css=bw.dom? 

document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." 
+obj):0; 
this.moveIt=b_moveIt; 
return this 
} 
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; 
this.css.top=this.y} 
function move(e){ 
x=bw.ns4 || bw.ns5?e.pageX:event.x 
y=bw.ns4 || bw.ns5?e.pageY:event.y 
if(bw.ie4 || bw.ie5) y=y+eval(scrolled) 
oCursor.moveIt(x+fromLeft,y+fromTop) 
}
But you still haven't really told us what you're trying to do. You haven't said when you want these text flags to show up or what you want them to say. You shouldn't expect us to dig through your code to figure out what it is you're trying to do.

Last edited by JimmySeal; 25-Dec-2008 at 01:49 PM..
Mr Red's Avatar
Computer Specs
Member with 74 posts.
 
Join Date: Dec 2008
29-Dec-2008, 12:12 PM #8
all I can do by way of explanation is to re-iterate in a different way.

layer visible with message as the alt/title becomes visible during hover.

Message in layer ideally mimic the alt/title message but at a lager font size. Though a single message of "Post Code Visible" is all I can do at present.

The reason I stick with old browsers is because there are folks out there who do also - they are the lowest common denominator. I know not who they are and I have a certain distaste for sites that assume you can see what they see - like Flash & no skip link & no text only version.

The missing code has probably been removed because there IE does not handle the tracking of the mouse in the same way as Mozilla based browsers, some functions have yet to be excised where that is a factor though in many cases it is handled by detecting IEX.X and not calling(IE7 is a law unto itself and has a security bug patch as of about 1 month ago). It does not affect the onMouseOver/onMouseOut functions.
Thanks for the consideration - I will go and investigate more. My current version is not posted - I have been through many recently.
JimmySeal's Avatar
Computer Specs
Member with 289 posts.
 
Join Date: Sep 2007
Experience: Getting there
29-Dec-2008, 12:45 PM #9
Please give us at least some hint of how you expect the code to behave (aside from what you expect the final result to be). Please name the relevant functions, how the layer is supposed to be generated, etc. As I've said, you cannot expect us to dig through a cryptic 300 line JavaScript file and make sense of the whole thing without any help from you.
Mr Red's Avatar
Computer Specs
Member with 74 posts.
 
Join Date: Dec 2008
30-Dec-2008, 09:02 AM #10
same explanation, different words - trial code:

named (id) div layer exists hidden (written in HTML)
onMouseOver shows layer (assigned in JavaScript)
onMouseOut hides layer ditto
Div layer should show words like "Post Code of venue is XY1 2PQ"
where text "XY1 2PQ" is unique to each link.

I have tried writing in HTML the code (where showlayer is a function using parameters)
Code:
<a HREF=............ alt="post code is XY1 2PQ"............ onMouseOver showlayer("XY1 2PQ")> etc </A>
but onMouseOver will not handle parameters. setting the onMouseOver call in JavaScript behaves the same the same. It refuses to call the function and all subsequent JavaScript stops.

The only way I can see to change the text of the layer uniquely is to have a function for each link (there might be 100 on the page). This may be the route I take. My pages are generated in Excel - VBA so I can program file making with the functions in a js file and reference it from HTML. e.g.:

Code:
<SCRIPT language=JavaScript src="pcodes.js" type=text/javascript>
</SCRIPT>
that way the functions load last or when called so the visible data are seen first.

the brainwave I had was to find out if I could
Code:
 
document.write("<script etc> functions etc </script>")
and I will be trying it - but before I do, has anyone tried writing JavaScript code with JavaScript? And what should I beware of?
JimmySeal's Avatar
Computer Specs
Member with 289 posts.
 
Join Date: Sep 2007
Experience: Getting there
30-Dec-2008, 10:20 AM #11
Now we're getting somewhere.

There's no reason why the onmouseover event of a tag shouldn't be able to invoke JavaScript that takes a parameter, but is this the syntax you're using?

<a HREF=..... alt="..."... onMouseOver showlayer("XY1 2PQ")>...</a>

onmouseover is a tag attribute like any other and must be used with the right syntax:

Code:
onmouseover="showlayer('XY1 2PQ')"
Also, my guess is that you will need some way of telling the method where to display the popup label, but that should be easy enough.

Now if you would just show us the showlayer code you have so far, perhaps one of us can try to get it working.
Mr Red's Avatar
Computer Specs
Member with 74 posts.
 
Join Date: Dec 2008
30-Dec-2008, 11:10 AM #12
I tried several permutations of quotes and double quotes.
Maybe because I am covering legacy browsers and restricting it to JavaScript 1.2 it doesn't work but I will try again.

I do have the option of calling simpler functions albeit having to generate multiple unique functions. I am braced for finding limits on storage, and speed. I will be back when I have some progress.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:20 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.