PDA

View Full Version : anylink link syntax



thinbegin
03-13-2006, 08:31 PM
Script: AnyLink
http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.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:

<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]:

menu1[0]='<a href="javascript:confirmExitSetup(\'./some_page.php\');">some page</a>'


thnx a lot!

thinbegin
03-13-2006, 09:01 PM
i believe that i may have found the [too easy] answer. can someone give their .02 worth on my solution?


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


thnx again..

thinbegin
03-13-2006, 09:13 PM
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:

http://mysite.com/reports/javascript:confirmExitSetup("./some_page.php");

but it should be generating the following:

javascript:confirmExitSetup("./some_page.php");

again, thanks for any help on this!

ddadmin
03-14-2006, 09:56 AM
Hmm escaping the quotes inside the function should have worked, for example:



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?

thinbegin
03-15-2006, 12:07 AM
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]:

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

ddadmin
03-15-2006, 09:18 AM
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.