SOLVED

Cannot include local copy of javascript file in Teams App Tab

%3CLINGO-SUB%20id%3D%22lingo-sub-1506609%22%20slang%3D%22en-US%22%3ECannot%20include%20local%20copy%20of%20javascript%20file%20in%20Teams%20App%20Tab%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1506609%22%20slang%3D%22en-US%22%3E%3CP%3EI%E2%80%99m%20trying%20to%20get%20a%20an%20HTML%20file%20to%20include%20a%20local%20javascript%20file%20but%20it%20does%20not%20seem%20to%20work%20in%20a%20Teams%20application%20tab.%20If%20I%20display%20the%20same%20HTML%20file%20in%20a%20web%20browser%2C%20it%20works%20fine.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%2C%20I%20have%20defined%20a%20string%20variable%20%E2%80%9CnewString%E2%80%9D%20in%20the%20file%20%E2%80%9Cdata.js%E2%80%9D%20and%20then%20attempt%20to%20pick%20it%20up%20in%20the%20HTML%20file%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E%0A.%20.%20.%0A%20%20%20%3CSCRIPT%20type%3D%22text%2Fjavascript%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fdata.js%22%3E%3C%2FSCRIPT%3E%0A.%20.%20.%0A%20%20%20%3CP%20id%3D%22test1%22%3Eoriginal%20value%3C%2FP%3E%0A.%20.%20.%20%0A%20%20%20%3CSCRIPT%20type%3D%22text%2Fjavascript%22%3E%20%0A%20%20%20%20%20%20document.getElementById(%22test1%22).innerHTML%20%3D%20%22test%3A%22%20%2B%20newString%3B%0A%20%20%20%3C%2FSCRIPT%3E%0A.%20.%20.%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20can%20see%20the%20value%20%E2%80%9Ctest1%E2%80%9D%20updated%20when%20I%20run%20it%20in%20Chrome%20but%20Teams%20does%20not%20seem%20to%20recognize%20%E2%80%9CnewString%E2%80%9D.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20this%20link%20which%20describes%20how%20to%20include%20MicrosoftTeams.min.js%20as%20a%20copied%20local%20file%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fjavascript%2Fapi%2Foverview%2Fmsteams-client%3Fview%3Dmsteams-client-js-latest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fjavascript%2Fapi%2Foverview%2Fmsteams-client%3Fview%3Dmsteams-client-js-latest%3C%2FA%3E%3C%2FP%3E%3CP%3EAccording%20to%20the%20documentation%2C%20it%20should%20work.%20Does%20anyone%20know%20what%20the%20problem%20is%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1506609%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ECommunity%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHow-to%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1529482%22%20slang%3D%22en-US%22%3ERe%3A%20Cannot%20include%20local%20copy%20of%20javascript%20file%20in%20Teams%20App%20Tab%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1529482%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F721379%22%20target%3D%22_blank%22%3E%40George71%3C%2FA%3E%26nbsp%3B%20%26nbsp%3BYou%20may%20want%20to%20open%20a%20request%20at%20our%20%3CA%20href%3D%22https%3A%2F%2Fanswers.microsoft.com%2Fen-us%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eanswers.microsoft.com%3C%2FA%3E%20tech%20support%20site%20for%20more%20personalized%20service.%26nbsp%3B%20I%20did%20a%20search%20on%20javascript%20there%20and%20found%20these%20items%20already%20posted%2C%20but%20you%20can%20open%20a%20new%20one%20if%20you%20don't%20see%20anything%20that%20applies%20to%20your%20situation.%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fanswers.microsoft.com%2Fen-us%2Fsearch%2Fsearch%3FSearchTerm%3Djavascript%2520and%2520teams%2520app%26amp%3Btab%3D%26amp%3Bstatus%3Dall%26amp%3BadvFil%3D%26amp%3BIsSuggestedTerm%3Dfalse%26amp%3BisFilterExpanded%3Dundefined%26amp%3BCurrentScope.ForumName%3Dmsteams%26amp%3BCurrentScope.Filter%3D%26amp%3BContentTypeScope%3D%26amp%3Bpage%3D1%26amp%3Bsort%3DRelevance%26amp%3Bdir%3DDesc%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fanswers.microsoft.com%2Fen-us%2Fsearch%2Fsearch%3FSearchTerm%3Djavascript%2520and%2520teams%2520app%26amp%3Btab%3D%26amp%3Bstatus%3Dall%26amp%3BadvFil%3D%26amp%3BIsSuggestedTerm%3Dfalse%26amp%3BisFilterExpanded%3Dundefined%26amp%3BCurrentScope.ForumName%3Dmsteams%26amp%3BCurrentScope.Filter%3D%26amp%3BContentTypeScope%3D%26amp%3Bpage%3D1%26amp%3Bsort%3DRelevance%26amp%3Bdir%3DDesc%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1534736%22%20slang%3D%22en-US%22%3ERe%3A%20Cannot%20include%20local%20copy%20of%20javascript%20file%20in%20Teams%20App%20Tab%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1534736%22%20slang%3D%22en-US%22%3Ethanks!%20%3A)%3C%2Fimg%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I’m trying to get a an HTML file to include a local javascript file but it does not seem to work in a Teams application tab. If I display the same HTML file in a web browser, it works fine.

 

For example, I have defined a string variable “newString” in the file “data.js” and then attempt to pick it up in the HTML file:

 

<head>
. . .
   <script type="text/javascript" src="data.js"></script>
. . .
   <p id="test1">original value</p>
. . . 
   <script type="text/javascript"> 
      document.getElementById("test1").innerHTML = "test:" + newString;
   </script>
. . .

 


I can see the value “test1” updated when I run it in Chrome but Teams does not seem to recognize “newString”.

 

I found this link which describes how to include MicrosoftTeams.min.js as a copied local file:
https://docs.microsoft.com/en-us/javascript/api/overview/msteams-client?view=msteams-client-js-lates...

According to the documentation, it should work. Does anyone know what the problem is?

 

Thanks!

 

2 Replies
Highlighted
Best Response confirmed by George71 (Occasional Contributor)
Solution

Hi @George71   You may want to open a request at our answers.microsoft.com tech support site for more personalized service.  I did a search on javascript there and found these items already posted, but you can open a new one if you don't see anything that applies to your situation.  https://answers.microsoft.com/en-us/search/search?SearchTerm=javascript%20and%20teams%20app&tab=&sta...

Highlighted