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 becaus开发者_运维百科e it makes no sense, but I'm just guessing?
Any ideas or workarounds appreciated!
use
<a href="#" onClick="addtext('á');return false">á</a>
and
<a href="#" onClick="addtext('\n');return false">Linefeed</a>
or
<a href="#" onClick="addtext('%0D%0A');return false">CRLF</a>
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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论