Board Thread:Support Requests - Getting Technical/@comment-25793496-20140621163544/@comment-856287-20140622045311

That would create a span with the class "insertusername," so everything within the span would be replaced with your username. The "onclick" function happens when you click the span element.

So, no "function" in the onclick event, just call the function you want like onclick="javascript:UserNameReplace;"

…and since it's a span with class="insertusername" you get a button like…


 * Iynque

…or like


 * Insert text for button to display username of reader

…if you're not logged in.

If you wanted the username replacement to wait until you clicked the button, you would have to edit the javascript, removing the last line, "addOnloadHook(UserNameReplace);" which is executing the UserNameReplace function "on load." Then you make a button to call the script like this:

So you would see Replace user name. and then click it and it would turn into Iynque

…BUT… you have to put this span into a MediaWiki page and then place it with  tags in order to make the javascript onclick event work. Otherwise it will be stripped when the page is generated. The reason for this is… well, you don't want just any anonymous user to be able to put javascript links into a page 😃