Code Link: here
So, on this given webpage I am doing just repeating data entry task. And I thought to use JavaScript to make things easier.
When I wrote the code, it just doesn’t let me do anything. Like I can’t use any event triggers, not even any tedious functions. Even I can’t access the input fields until unless I go into developer tools and specifically select ‘about:srcdoc’ and only then it finds the elements it needs to.
I have never faced this issue. How can i solve this from client side to do what i was doing.
The code i was running is below:
// Function to handle the onchange event
function handleChange(event) {
// Subtract 50,000 from txtListingPriceLow
document.querySelector('input[id="txtListingPriceLow"]').value = (
(parseFloat(document.querySelector('input[id="txtListingPriceLow"]').value.replace(/[^0-9.-]/g, '')) - 50000)
).toFixed(2);
}
// Add event listener to the input element
var inputElement = document.querySelector('input[id="txtListingPriceLow"]');
if (inputElement) {
inputElement.addEventListener('change', handleChange);
} else {
console.log('Input element not found');
}
It throws the error like:
Blocked script execution in ‘about:srcdoc’ because the document’s frame is sandboxed and the ‘allow-scripts’ permission is not set.