using js with less elements
Hi,
as i seen this page, i wanted to ask for help, today i've wanted to write a "randomize text code without the javascript display in the elements but i couldn't do it can someone tell me what i did wrong and correct me it? also this is an example i want to be same as this.
https://api.rtainc.co/twitch/8ball
and this is my code
- <html>
- <shadow><script type="text/javascript">
- var textarray = [
- "Hi, $(user)",
- "Welcome, $(user)",
- "how r u $(user)",
- "HYD $(user)"
- ];
- function RndText() {
- var rannum= Math.floor(Math.random()*textarray.length);
- document.getElementById('txt').innerHTML=textarray[rannum];
- }
- onload = function() { RndText(); }
- </script></shadow>
- <head></head>
- <body>
- <pre id="txt" style="word-wrap: break-word; white-space: pre-wrap;"></pre>
- </body>
- <style></style>
- </html>