View Full Version : Javascript link within Javascript Generator

10-26-2006, 08:05 PM
I wrote a javascript a long time ago that randomly generates 5 images with specified links, but is coded so it doesnt repeat any of the images. Its quite useful, I will share if people wish.

However the original array was:
theImages[0] = "<a target='_blank' href='http://www.google.com/'><img src='images/google.gif' alt='google'></a>";

What i was trying to do today was:
theImages[0] = "<a href='javascript:popUp('images/full/paul1.jpg')'><img src='images/prev1.gif' id='midimg'></a>";

I have a pop-up script running on the site already - but nothing happens. the pop-up script is fine. the images get called by the generator but the links don't work.

I am very rusty at JS and don't have my books anymore. I would appreciate if somone could give me a shunt in the right direction!

10-26-2006, 11:07 PM
The problem is that the href=' is opened by a single quote, and you closing it again with ('... so you should change one of the two, I should go for this one:

theImages[0] = "<a href='javascriptopUp(\"images/full/paul1.jpg\")'><img src='images/prev1.gif' id='midimg'></a>";

10-27-2006, 01:56 AM
Worked like a charm!

Thanks. :thumbsup: