js load img
var elements = [];
function loaded(){
console.log("you have loaded an image");
}
CreateFileFrom("your/dir/here/img.png");
function CreateFileFrom(dir){
/* defining runtime variables */
var extension = dir.split('.').pop();
var keys = {"png":"IMG","jpg":"IMG","jpeg":"IMG",
"js":"SCRIPT","json":"SCRIPT",
"mp3":"AUDIO","wav":"AUDIO"};
var obj = document.createElement(keys[extension]) || {};
obj.src = dir;
/* onload function called when the resource is loaded */
obj.onload = (e) => {
elements.push(e.path[0]);
loaded()
}
/* make sure that the data is compitable */
if(keys[extension]==null){console.error("not supported media type "+extension);return;}
}
Also in JavaScript:
- indexing string in javascript
- how to find out which version of React
- react template
- on enter key press react
- w3schools angular
- getting the value of pi in javascript
- javascript pad with leading zeros
- nvm show available versions
- react navigation stack
- node express mongo boilerplate with jwt
- jquery if else on click
- client timezone offset in JavaScript
- vscode entenstion build
- ng has unexpectedly closed (exit code 127).
- file origin does not match viewer's pdf.js
- array js fill
- math.random js
- javascript console error
- create json model online
- jest axios manual mock
- devtools failed to load sourcemap when debugging react native
- for in javascript
- javascript for
- constructor react