A snippet I posted just now gives me this error in Firefox when I invoke a JavaScript function (by clicking the checkbox):
"message": "Error: Permission denied to access property Symbol.toPrimitive",
"filename": "https://stacksnippets.net/js",
"lineno": 39,
"colno": 5
and this one in Chrome:
"message": "Uncaught SecurityError: Blocked a frame with origin \"null\" from accessing a cross-origin frame.",
"filename": "https://stacksnippets.net/js",
"lineno": 39,
"colno": 24
and I don't understand why. I don't access any other elements than the ones on the page, and a jsfiddle with identical code works fine, without warnings.
So my questions are
What goes wrong? Is this a bug in the snippet system?
If it's not a bug, but a security feature, how do I work around it? What could I have written instead of the current JavaScript to make it function just like the jsfiddle?
This is the snippet that produces the error
var popup = document.querySelector('section img');
var top = popup.offsetTop;
document.getElementById('more').onclick = function() {
if (document.getElementById('more').checked)
popup.style='top: '+top+'px; margin:0';
else {
popup.style=''; top = popup.offsetTop;
}
};
section {
position: relative;
}
#more:not(:checked)~p {
display: none
}
section img {
position: absolute;
left: 50%;
top: 0;
bottom: 0;
margin: auto 0;
}
<section>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<input id="more" type="checkbox"><label for="more"> Show more</label>
<p>Hoc est clamabunt angustia vocatione in fodienda navis rubrum nanum. De cantavit sunt mortuis, occidit per radialis effluo. Solus superstites es dave lister, qui erat in suspensa animationem in cladis, et suus gravida felis, qui tuto signati in præsidium.
Revixit tres decies annis post, lister scriptor tantum comites a vita forma qui evoluta ex suus cattus, et a hologram simulatio unum mortuorum cantavit. Nuntius fines.</p>
<img src="https://placehold.it/150x100" alt="150x100"/>
</section>