Okay. So here's what I'm trying to do. I have my landing page to my site and near the bottom I have 4 little 48x48 class divs (for social network link images if you were wondering ). Each Class div has a background style all to it's own. (so in this case 4 different divs with 4 different class names) .
What I want to do with the javascript is to have a function(s) that when called on (depending on which div.class was/is clicked on) will open up a lightbox/new page containing the new page (pertaining to the appropriate social network, depending on which class has been clicked on).
I don't want to put an <a></a> tag around the div.classes themselves seperately because the landing page itself has 8 different styles, plus the div.classes I would have to hunt down within the site itself. haha
Basically in short I want the classes to have seperate links that when clicked upon it calls the function, opens the lightbox (or opens the new tab/page) and loads the appropriate page.
Do you mean you want to put all this in some .js file that can be used on various pages? So the code has to search for the <div class="foo"> and <div class="bar"> and so on divs and attach the onclick handler to each one, appropriately?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
I don't want to put an <a></a> tag around the div.classes themselves seperately because the landing page itself has 8 different styles, plus the div.classes I would have to hunt down within the site itself. haha
What about when JavaScript is off? Nobody will be able to go to Facesucks, Youboob, or MyFace anymore...
You already said it, but yeah... just wrap the divs with some <a> tags - makes more sense. However, if you still want to do this, Bullant already got you started. If you are stuck, just post your script and questions here and someone will "serve" you a solution.
Good :Luck!
__________________
I don't know, I don't care, and it doesn't make any difference!
-Albert Einstein-
Maybe something like this will work for you, but if you want it to pop up in a new window, you must use window.open(). It validates just fine, however you should make a function so it isn't inline.
Many nowadays will argue that both inline styles and inline javascript is "old hat".
Maybe use this demo option as a guide (which is slightly different to the other option I posted earlier)
The iconsData 2D array contains the info needed to created your social network clickable <divs>.
Each row of iconsData contains the image file name for the icon and the url to go to when the icon is clicked.
You can add/remove as many rows in the array as you like without having to touch the rest of the javascript or html. The divs and their functionality are created automatically in the window.onload event handler.