It's impossible to say without seeing your code in context, but there certainly are lots of issues with what you did post.
First, your linkToIt() function won't work as is. I'm guessing you want window.location = linkArray[ran]; instead of windows.location = linkArray[ran]; and I'm assuming you've defined both linkArray and ran somewhere else in scope. Second, my understanding is that the href="javascript:" syntax is deprecated. I'd recommend using on onclick handler instead, something like this: <a href="#" onclick="linkToIt(); return false;"><img ... /></a> Note also that you had some extra spaces inside the <a> tag, specifically after the href attribute name. I wouldn't be surprised if this caused problems on some browsers. Third, the target="_blank" you had won't work with the window.location syntax you're using. If you want a URL opened from JS to be in a new browser window, you'll need to use the window.open function, rather than the location property. Alternately, you could set the href attribute of the link from JS (rather than calling JS when the link is clicked), but that'd be a bigger rewrite. HTH, String On Aug 3, 12:54 am, ntuple <[email protected]> wrote: > Hi, > > Am a newbie to gadgets and am having trouble with a simple task. I'm > making a gadget displaying random images from an array and linking > them to corresponding URLs in my domain using a function like this: > > function linkToIt() > { > windows.location= linkArray[ran]; > > } > > The link call is this: > > <a href ="javascript:linkToIt()" target="_blank"> <img > name="dogOfDay" width=100 height=80 /> </a> > > This is giving me a "linkToIt() is not defined error". In plain > Javascript I'd expect to put the function in the <head> so it can be > recognized, but as this is not possible in a gadget how can I define a > link dynamically based on a variable ? > > thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "iGoogle Developer Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Gadgets-API?hl=en -~----------~----~----~----~------~----~------~--~---
