Forum Moderators: phranque
I want to implement some kind of on-the-fly rewrite whereby any technical term that comes up on my website is automagically generated with a (e.g.) piece of javascript that on mouseover, pops up a small box (layer) that provides a definition of said item.
What's the best way of going about this? The same term would appear a number of times over a number of pages - so I guess this could be done at some library level, but I thought doing it at the webserver level might be easier?
Of course, then there's the possible processing overhead ... but I'm just guessing randomly now. Does anyone have any suggestions? I looked at mod_rewrite, but that seems to be just for URLs, rather than content.
Any assistance or helpful tips would be much appreciated =)
I'll eventually have about 6 different languages on the site, and it's not just the product description(s) that'll require the mouseover things - it'll also be part of the product attribute descriptions (if that makes any sense to anyone).
When you say javascript library ... does that mean ajax-esque?
Or did you envisage a library with all of the definitions in each of the languages?
10 separate definitions x 6 languages = 60? Or would they be calls to the DB, which would then be 'mouseovered' via the javascript lib?
Sorry if I'm sounding dense, I'm just trying to get a better understanding of what you mean
Thanks,
m
I'll eventually have about 6 different languages on the site, and it's not just the product description(s) that'll require the mouseover things - it'll also be part of the product attribute descriptions (if that makes any sense to anyone).
TBH I've never done this, my response was just more of a conceptual thing based on my experience with scaling other services and seeing what other places have done. Look at the way some advertising works (intellitext, amazon), because it'll be very similar.
Conceptually you'd load the page and include a javascript library that has the smarts to parse the page and rewrite the DOM based on a set of rules. The rules would be downloaded through xmlhttprequest() (ie ajax) by the first javascript library once it figured out what language or section of the site, or whatever.
The rules could come from a database or a static xml/json file. It depends on how much data there is -- you don't want to download your whole product catalogue if there are only 3 different "things" that you'll be highlighting on the page, the database approach might be better.
This might be overkill for what you want, it might not.
Sean