Results 1 to 3 of 3

Thread: Implementing an array with javascript:jumpto

  1. #1
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Implementing an array with javascript:jumpto

    1) Script Title:

    Drop-down Document Viewer II

    2) Script URL (on DD):

    http://www.dynamicdrive.com/dynamici...pdownview2.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

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You need to escape the single quotes using backslashes: ' becomes \', so your menu1[0] would be:
    Code:
    menu1[0]='<a href="javascript:jumpto(\'http://www.cnn.com\');">test</a>';
    You can also use double quotes and escape them as HTML entities:
    Code:
    menu1[0]='<a href="javascript:jumpto(&quot;http://www.cnn.com&quot;);">test</a>';
    Personally, I think the former is more readable.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That works perfectly...thanks, you made my year!!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •