Improved Javascript Injection


#21

Hey Sam, try wrapping your script examples in backticks to bypass the Markdown/HTML parser:

some code here with as many \ backslashes \ as you want

You can also access this formatting by highlighting your text and clicking the Preformatted text icon, </>, at the top of the message editor.


#22

Excellent. It works. Thanks!


#23

I implemented voice in my prototype: https://9vtssu.axshare.com/#g=1&p=chatbot
I discovered that changing the “I’m” to “I am” in the widget allows Watson to speak.


#24

Hi sam.hepworth,

May I ask you if you could please share your expertise on how to fix errors that show up in MSIE and Firefox when trying to run javascript calls. I have 2 events OnShow and OnLoad code.
Here link to page with error: [Error in Firefox and MS Edge]
(https://sjlif6.axshare.com/#g=1&p=ask_watson_chatbot&c=1)

I tried to resolve this but couldn’t figure out.

Voice-Js -browser error.rp (97.8 KB)

Preview for attached file.
Please click to
Here I use javascript code:

javascript:var jsurl_one = document.createElement('script');
jsurl_one.setAttribute("type", "text/javascript");
jsurl_one.setAttribute("src", "https://code.responsivevoice.org/responsivevoice.js");
var head = document.getElementsByTagName('head')[0];
head.appendChild(jsurl_one);


javascript:responsiveVoice.speak('[[LVAR1]]', "US English Male");

Would appreciate your any help and advice!
Natalie


#25

Hi Natalie,

You can try this version:
Voice-Js -browser error-Sam.rp (98.8 KB)

When you execute javascript in “open link in current window” the javascript should return void or valid html. I have wrapped your javascript like this:

javascript: (function (){
< Your javascript here >
})();

This way you are sure to return void and it also helps you to not create unintentional global variables.

/sam


Solved: Link not working in Firefox and MSIE 11
#26

Wow, with this small line of script you saved a prototype that I did during a month. I fixed all voice over parts for Artificial intelligence. No more error message.:tada:

Million of thanks,
Natalie


unlisted #27

closed #28