My script code is not being called when I load the nested HTML in my electron app and I cannot figure out why.
<div id="leftsidebar">
</div>
<div id="rightsidebar">
</div>
<div id="main" class="mainContent">
</div>
<script>
const fs = require('fs');
// Loads the html required for the side bar
fs.readFile('leftSideBar.html', (err, data) => {
document.getElementById('leftsidebar').innerHTML = data;
});
fs.readFile('rightSideBar.html', (err, data) => {
document.getElementById('rightsidebar').innerHTML = data;
});
function loadMainWindowHTML(htmlString) {
fs.readFile(htmlString, (err, data) => {
document.getElementById('main').innerHTML = data;
});
}
</script>
This is the main HTML code in my main window, and when I click on an item in my left side bar, it should execute loadMainWindowHTML() with the HTML file I want to open.
<div id="myleftSidebar" class="leftSideBar">
<a href="#" onclick="loadMainWindowHTML('searchUser.html')">Search User</a>
</div>
The HTML file is called like this and loaded into the div with the id of main properly, however, the script in searchUser.html is never executed.
<head>
<title>Document</title>
<script>
console.log("do we reach?");
</script>
</head>
The log never appears anywhere. Any explanation or fix for this?