I’ve got this javascript:
<a href="javascript:addtext('q');">q</a>
When it is clicked it writes text on a textarea.
I went through the encoding and found can do things like this:
This will add a ” ” (Space)
<a href="javascript:addtext('%20');">Space</a>
And this will add an “á”
<a href="javascript:addtext('á');">á</a>
Now I want to know how to add the return value. (enter)
As far as I know this are URL encodings so maybe you cant tu the enter value because it makes no sense, but I’m just guessing?
Any ideas or workarounds appreciated!
use
and
or
The reason for not using the javascript: protocol is that some browsers actually unload the page when you do not return false on an onClick. It is possible to do javascript:void(somejavascript()) to achieve the same thing, but that will give a 404 if the user has turned JS off. Not a huge issue in your app which only works if JS is on, but onClick and return false is the canonical way.
I would actually put the return false as the last statement in function addText, and do onClick=”return addtext(…)” instead.