3

let's assume that the content is empty as given below.

<head> 

</head>

If I want to change it dynamically to

<head> 
<script src="jquery-1.8.0.min.js"></script>
</head>

is there anyway that AppInventor can do that?

3 Answers 3

3

You can select it and add to it as normal:

$('head').append('</script>');

JavaScript:

document.getElementsByTagName('head')[0].appendChild( ... );

Make DOM element like so:

script=document.createElement('</script>');
script.src='src';

document.getElementsByTagName('head')[0].appendChild(script);
Sign up to request clarification or add additional context in comments.

2 Comments

I dont think he might want to use jQuery though.
var script = //... would be a better solution. Declaring global variables pollutes the window object.
1

Some simple javascript to change the innerHtml of document.head will work

document.head.innerHTML = "<script src=\"jquery-1.8.0.min.js\"></script>";

Comments

0

How about:

var HeadScript = document.createElement("SCRIPT")
HeadScript.src = "jquery-1.8.0.min.js"
document.head.appendChild(HeadScript)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.