I have a calculator that is inside of an iframe.
<iframe id="tool_iframe" scrolling="no" height="750" srcdoc="
<html>
<head>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
body{
height:100vh;
background-color: #4158D0;
background-image: linear-gradient(43deg, #4158D0 0%, #C850C0 46%, #FFCC70 100%);
font-family: 'Poppins', sans-serif;
background-position:center center;
}
.container {
width: 520px;
background-color: #ffffff20;
margin: 120px auto;
}
table {
width: 100%;
border-color: transparent;
font-family: 'Poppins', sans-serif;
border-radius:20px;
}
td {
width: 25%;
}
button {
width: 100%;
height: 90px;
font-size: 32px;
background-color: white;
border: none;
color:#273342;
}
#inputLabel {
height:100px;
font-size: 60px;
vertical-align: bottom;
text-align: right;
background-color: #27334210;
color:white;
padding:0 10px 0 0;
font-family: 'Poppins', sans-serif;
border-top-radius:20px;
}
</style>
<script>
var inputLabel = document.getElementById('inputLabel');
function pushBtn(obj) {
var pushed = obj.innerHTML;
if (pushed == '=') {
//Calculate
inputLabel.innerHTML = eval(inputLabel.innerHTML);
} else if (pushed == 'AC') {
//All clear
inputLabel.innerHTML = '0';
} else {
if (inputLabel.innerHTML == '0') {
inputLabel.innerHTML = pushed;
} else {
inputLabel.innerHTML += pushed;
}
}
}
</script>
</head>
<body>
<html>
<body>
<div class="container">
<table border="1" cellspacing="0">
<tr>
<td colspan="4" id="inputLabel">0</td>
</tr>
<tr>
<td colspan="3"><button onclick="pushBtn(this);">AC</button></td>
<td><button onclick="pushBtn(this);">/</button></td>
</tr>
<tr>
<td><button onclick="pushBtn(this);">7</button></td>
<td><button onclick="pushBtn(this);">8</button></td>
<td><button onclick="pushBtn(this);">9</button></td>
<td><button onclick="pushBtn(this);">*</button></td>
</tr>
<tr>
<td><button onclick="pushBtn(this);">4</button></td>
<td><button onclick="pushBtn(this);">5</button></td>
<td><button onclick="pushBtn(this);">6</button></td>
<td><button onclick="pushBtn(this);">-</button></td>
</tr>
<tr>
<td><button onclick="pushBtn(this);">1</button></td>
<td><button onclick="pushBtn(this);">2</button></td>
<td><button onclick="pushBtn(this);">3</button></td>
<td><button onclick="pushBtn(this);">+</button></td>
</tr>
<tr>
<td colspan="2"><button onclick="pushBtn(this);">0</button></td>
<td><button onclick="pushBtn(this);">.</button></td>
<td><button onclick="pushBtn(this);">=</button></td>
</tr>
</table>
</div>
</body>
</html>
</body>
</html> "></iframe>
The actual website is https://tropical.team/tool/calculator/ if you want to take a look for yourself. You can see when you load in everything loads fine but the calculator just doesn't work, i know the code is valid because when i copy the script from the head of the iframe and paste it into the consxole it workks. This must mean that it's a problem with the document.reference not working inside the iframe. The calculkator code is user made which means i can only modify it automaticaly in minor ways, like changing all document
references to something else. What could i chage them to that would generally fix this?