user5045
user5045

Reputation: 241

Change HTML <head> content using javascript/jquery

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?

Upvotes: 3

Views: 19045

Answers (3)

Shtefan
Shtefan

Reputation: 808

How about:

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

Upvotes: 0

underscore
underscore

Reputation: 6887

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);

Upvotes: 3

Zero Fiber
Zero Fiber

Reputation: 4465

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

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

Upvotes: 1

Related Questions