Add script to  element

Add script to  element



I'm creating a web app integrated with Yammer. I'm unable to add the following script to the head element:

<script type="text/javascript" data-app-id="YOUR-APP-CLIENT-ID" src=""></script>

I tried using the AddJavascriptTag in HHTPRequestHandler where I assigned the URL as:

""""" data-app-id=YOUR-APP-CLIENT-ID"

But this is not working on. On inspecting in Chrome, the script tag appears as follows:

<script type="text/javascript" src="" https:="""" assets="" platform_js_sdk.js"="" data-app-id="wZuyoeLNhd1SR6pF5faXUg""></script>

How else do I achieve this?

I've also tried retrieving the head ID using getElementByID. That also doesn't seem to be working.


You can try this using an expression:

SyntaxEditor Code Snippet

    document.write('<script type=""text/javascript"" src="""" data-app-id=""your-app-id""><\/script>');

Please be aware your data-app-id is in your question.

I think you can create a js script as resource file and include this one through HTTPRequestHandler AddJavascriptTag

Good luck

Hi Barong,

How do you get the 


part in the script tag in your solution?

hi Johan,

i tried like this in the JavaScript property of the screen:

SyntaxEditor Code Snippet

var s = document.createElement("script");
    s.type = "text/javascript";
    s.src = "";, "data_app_id", "YOUR-APP-CLIENT-ID" );
    // Use any selector
     alert("here==" + s, "data_app_id" ));

however, i am fail if using https, instead of http for the src.

and i cannot alert the result in a button, but it works, always undefined:

SyntaxEditor Code Snippet (not work in button - RunJavascript... httprequesthandler...)

var s = document.createElement("script");
    s.type = "text/javascript";
    s.src = "";, "data_app_id", "YOUR-APP-CLIENT-ID" );
    // Use any selector
     //alert("here==" + s, "data_app_id" ));



You should get ride of the http:// I think just do:

s.src = "//";

If you application is on http it will use http. is you application on https if will be on https too.

Let me know if it works.