Hi ,
When i am try to paste my code inside run JavaScript function on a browser activity, it is giving syntax error, while the same code is executable on other IDE.
For the time being i am using this via reading the code from a text file then pasting it in JavaScript activity.
But since this will involve dependency on a file and i need to get rid of this dependency , so kindly suggest what could be the reason of this syntax error, or if there is an alternative of this read from file without involving any dependency on external file.
I have tried using str variable , it also gives Invalid value when i paste my code in it.
Below is my js code
function openModal() {
let BasicModalData = document.createElement('div');
BasicModalData.setAttribute('id', 'BasicModalData');
BasicModalData.innerHTML = `
<style>
/* Styles for the modal */
.modal {
position: fixed;
top: 50%;
left: 50%;
border: 1px solid #888;
margin-left: 25px;
padding: 20px 20px;
text-align: Center;
transform: translate(-50%, -50%);
z-index: 1000;
display: block;
border: 1px solid #888;
width: 40%;
margin: auto;
height:25%;
background-color: AliceBlue;
font-family: 'Monaco', Monospace;
font-size: 25px;
font-weight: bold
}
.button-container { text-align: center; position: absolute; bottom: 10px; width: 100%; }
.button-container input { margin-right: 16px; }
</style>
<!-- Modal -->
<div id="BasicModal" class="modal">
<p>Virtual Bot Voluntary Changes Execution Started......</p>
<div class="button-container">
<button onclick="closeModal()">Close</button>
</div>
</div>
`;
let existingFlightData = document.getElementById('FlightData');
if (existingFlightData) {
document.body.removeChild(existingFlightData);
}
let BasicModaldata = document.getElementById('BasicModalData');
if (BasicModaldata) {
document.body.removeChild(BasicModalData);
}
document.body.appendChild(BasicModalData);
document.getElementById('BasicModalData').style.display = 'block';
setTimeout(function() {
closeModal();
}, 3000);
}
function closeModal() {
let basicModalData = document.getElementById('BasicModalData');
if (basicModalData) {
basicModalData.style.display = 'none';
document.body.removeChild(basicModalData);
}
}
openModal();