Jump to content

on mouseover event


Elemental

Recommended Posts

Hey Folks, In my on going search to learn, learn, and learn some more, I ask the following question...I came upon this site, one of many I'm sure, and wondered how it was being done so I took a look at the Source and to my surprise the <a> tag I expected to find was not there so ....Here's the link:http://www.howtodothings.com/computers/a27...d-document.htmlMy question is on those double under-lined links, and how are they doing the roll over event when there is no <a> tag and no id= reference for it either?Peace,Elemental

Link to comment
Share on other sites

Thats done using JavaScript. If you get a debugger like FireBug you can see the post-runtime HTML being generated, those text bits are being put into spans with IDs.

Link to comment
Share on other sites

Synook, Thanks for your reply

Thats done using JavaScript. If you get a debugger like FireBug you can see the post-runtime HTML being generated, those text bits are being put into spans with IDs.
Is there a benefit to doing it this way versus just coding the actual document?
Link to comment
Share on other sites

No, it's actually bad, because if the user has Javascript disabled it will not appear.The reason advertisers do it is because it lets them easily put ads into a user's page.

Link to comment
Share on other sites

Is there a benefit to doing it this way versus just coding the actual document?
It's beneficial if 1) you are a third-party that provides a service (such as that advertiser) and 2) if you have hundreds of elements that need to have onmouseover events handled, it's much easier to do so programatically rather than to hard-code them into the source HTML.
Link to comment
Share on other sites

Actually, there are several major benefits to doing it that way. This is an advertising feature. Advertisers buy terms to advertise on, so someone might buy "Microsoft Word" and choose to show their ad when someone hovers over that term. First off, chances are the people writing the articles are not programmers. You don't want the people writing the articles to put a bunch of HTML markup in there to highlight advertising terms. It's not something a writer should be expected to know or do, that's not their job. So one benefit is that nothing extra is required on the part of the people doing the writing, you just attach a piece of Javascript to any page and it will scan through it to find the terms and highlight them. A second benefit is what happens if an advertiser wants to advertise on "WordPerfect" instead of "Microsoft Word". Are you going to go through all the code for all the articles and change a bunch of hard-coded links? If so, then you're doing it wrong. It would be better to update in some database that the term has changed and then it's the Javascript's responsibility to find the new term and highlight it. Also, since 94% of people browse with Javascript enabled, it's far more valuable to use a Javascript method to add the highlighting instead of hard-coding everything to pick up that extra 6% of people. Using Javascript is also preferred to using a server-side script because you can attach the Javascript file to any existing web page to highlight, it doesn't require changing any code, you just add the script.

Link to comment
Share on other sites

Ingolme, jesh, justsomeguy, Thank you for your replies, it's appreciated.Where can I learn more about this type of JavaScript coding?When I look at the source I don't see any actual JavaScript it's more like links to JavaScript documents, is this the case?I did as Synook advised and downloaded FireBug but I'm still a little confused as to how this POST-RUNTIME thing works, are there any articles on this site that explain it a bit further; if yes then just say so, I'll look them up.I tried a google search on post-runtime and runtime and what I got were runtime error returnsPeace,Elemental

Link to comment
Share on other sites

There is quite a bit of Javascript code on that page. There are some links to external scripts, and some inline code. This is the part that includes the highlighting script:

<script type="text/javascript">var dc_UnitID = 14;var dc_PublisherID = 22350;var dc_AdLinkColor = 'blue';var dc_isBoldActive= 'no';var dc_adprod='ADL';</script><script type="text/javascript" src="http://kona.kontera.com/javascript/lib/KonaLibInline.js"></script>

I'm not sure how well it works though. It highlighted the phrase "dialog box" and showed this when I hovered over it:

Find BoxSave up to 50% on Box. Search over 15,000 sites with one click. Your source for everything under the sun!
Yeah.. exactly what I'm looking for.. "Box", for 50% off no less.
Link to comment
Share on other sites

justsomeguy, Thanks again,Yeah, funny I never rolled over that one. I actually noticed the mouseover event on accident, when the page loaded the mouse was over the link. I didn't mean it to sound like there was no JavaScript on the page, I did see some but it mostly looked like they were external ones and that's why I made the comment.The JavaScript you make reference to, the one that begins with SRC="http://...." would that be the link to the external JavaScript file for those mouseover events I mentioned?Peace,Elemental
Link to comment
Share on other sites

That line contains the link to the script, right. It belongs on the same line as the part before, I edited the code above. The script is hosted at kontera.com, if you go to that site you can see how to use it. They probably pay some sort of commission for clicks or something. The code above that line sets a bunch of variables that the script uses, like for example it sets the color to blue.

Link to comment
Share on other sites

justsomeguy, Thanks for the help.I keep adding things to my "to learn list" CSS, HTML, JAVASCRIPT, PHP, ETC, ETC... I should have kept to music.Peace,Elemental

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...