Results 1 to 6 of 6

Thread: anylink link syntax

  1. #1
    Join Date
    Mar 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default anylink link syntax

    Script: AnyLink
    http://www.dynamicdrive.com/dynamici...pmenuindex.htm

    hey there. does anybody know how i can pass the following syntax correctly? i am having trouble with the quotes. the idea [probably obviously] is to output a link that calls another javascript function through the href. thnx.

    this syntax works inside a normal [non 'AnyLink"] anchor:
    Code:
    <a href="javascript:confirmExitSetup('./some_page.php');">some page</a>
    in the AnyLink array, i have plugged it in like so [trying to excape some quotes]:
    Code:
    menu1[0]='<a href="javascript:confirmExitSetup(\'./some_page.php\');">some page</a>'

    thnx a lot!

  2. #2
    Join Date
    Mar 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i believe that i may have found the [too easy] answer. can someone give their .02¢ worth on my solution?

    Code:
    menu1[0]='<a href="javascript%3AconfirmExitSetup(%22some_page.php%22)%3B">some page</a>'

    thnx again..

  3. #3
    Join Date
    Mar 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by thinbegin
    i believe that i may have found the [too easy] answer. can someone give their .02¢ worth on my solution?
    i spoke too soon.

    my "solution" now generates the javascript syntax appended to the end of the full url. the url now being created is:
    Code:
    http://mysite.com/reports/javascript:confirmExitSetup("./some_page.php");
    but it should be generating the following:
    Code:
    javascript:confirmExitSetup("./some_page.php");
    again, thanks for any help on this!

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm escaping the quotes inside the function should have worked, for example:

    Code:
    function say(what){
    alert(what)
    }
    
    menu1[0]='<a href="javascript:say(\'hi\')">JavaScript Kit</a>'
    The above when clicked on causes "hi" to be alerted.

    Make sure that the function you're trying to call actually works as expected. It seems you're passing a PHP page into your JS function- what are you trying to accomplish?

  5. #5
    Join Date
    Mar 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thnx ddadmin. i have verified all of that.

    just to finish up, the solution is the following [its a mix of html-encoding and not]:
    Code:
    menu1[0]='<a href="javascript:confirmExitSetup(%22some_page.php%22)%3B">some page</a>'

  6. #6
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm encoding definitely should not be necessary. Backspacing alone may not do it with some more complex functions, but you shouldn't need to encode anything. I can't remember the various solutions there are for this, but there definitely are alternatives.

    But I guess bottom line, if it works now for you, that's all that matters.

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
  •