eval is actually not recommended but for your example this should work:
b.onclick=eval('function clickHandler(){TogetherJS(this); return false;}');
or better use this:
b.onclick=function(){TogetherJS(this); return false;};
Question
Entering the following code in the URL bar (in safari) creates the required script tag and button in order to run Together.js:
javascript:{var s=document.createElement('script');
s.src='https://togetherjs.com/togetherjs-min.js';
document.head.appendChild(s);
var b=document.createElement('button');
b.onclick='function(){TogetherJS(this); return false;}';
b.innerHTML='Start TogetherJS';document.body.appendChild(b);}
However, the onclick
property of the button is not set. I have also tried setting the onclick
property to a string value but have had no luck. How can I set the onclick property of the button?
PS. This is one of my first questions. Is there any thing I could improve?
La solution
eval is actually not recommended but for your example this should work:
b.onclick=eval('function clickHandler(){TogetherJS(this); return false;}');
or better use this:
b.onclick=function(){TogetherJS(this); return false;};