-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathincluir.js
More file actions
32 lines (30 loc) · 747 Bytes
/
incluir.js
File metadata and controls
32 lines (30 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Manipulando a DOM (<head>)
*
* @param {String} $arquivo [Nome do Arquivo que deseja incluir]
* @return {Bollean} false
*/
function incluir($arquivo){
var divisao = $arquivo.split(".");
var ext = divisao[divisao.length-1];
var head = document.getElementsByTagName("head").item(0);
switch(ext) {
case "js":
var elemento = document.createElement("script");
elemento.src = $arquivo;
head.appendChild(elemento);
break;
case "css":
var elemento = document.createElement("link");
elemento.href = $arquivo;
elemento.rel = "stylesheet";
head.appendChild(elemento);
break;
default:
alert("extensão errada");
break
};
return false;
}
incluir("myjavascript.js");
incluir("mystyle.css");