PDA

View Full Version : Implementing an array with javascript:jumpto



imfletcher
07-22-2007, 10:20 PM
1) Script Title:

Drop-down Document Viewer II

2) Script URL (on DD):

http://www.dynamicdrive.com/dynamicindex3/dropdownview2.htm

3) Describe problem:

I'm trying to use javascript:jumpto inside an to load an external page by using the "Drop-down Document Viewer II" script.

Here's what the array looks like that I'm trying to implement (see the first anchor tag in the first line to see what I'm trying):

var menu1=new Array()
menu1[0]='<a href="javascript:jumpto('http://www.cnn.com')">test</a>'
menu1[1]='<a href="http://www.freewarejava.com">test</a>'
menu1[2]='<a href="http://codingforums.com">test</a>'
menu1[3]='<a href="http://www.cssdrive.com">test</a>'
menu1[4]='<a href="http://www.cssdrive.com">test</a>'

It seems like I'm close but running into a syntax problem. Is what I'm asking even possible?

Thanks Reply With Quote

Twey
07-22-2007, 10:38 PM
You need to escape the single quotes using backslashes: ' becomes \', so your menu1[0] would be:
menu1[0]='<a href="javascript:jumpto(\'http://www.cnn.com\');">test</a>';You can also use double quotes and escape them as HTML entities:
menu1[0]='<a href="javascript:jumpto(&quot;http://www.cnn.com&quot;);">test</a>';Personally, I think the former is more readable.

imfletcher
07-22-2007, 11:29 PM
That works perfectly...thanks, you made my year!!!