Home > Back-end >  Dynamically loading div's through Javascript does not work with onload
Dynamically loading div's through Javascript does not work with onload

Time:08-25

I am making use of a localstorage to store all my information about bugs and other things such as users. I want to loop through my localstorage and create a div for each specific record (records that contain keys with "Bug" in them) so I created this: Function that dynamically adds div's

Then I want to make it so it runs this function when the webpage loads so I do this in my html file: Running the function when the webpage loads

But then it does not insert my div's, when I test the function on a button's onclick event it works perfectly fine.

CodePudding user response:

Remove the src attribute from the script tag. Because the script tag has a src attribute your code is ignored.

CodePudding user response:

Your windows.load function should be separate, in it's own script tag.

<Script type="text/javascript"> 
window.load = function(){ LoadBugs; }; 
</script>

and the script reference added like this:

<script src="processes.js"></script>
  • Related