I currently use
<script src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if (window.location.href.indexOf("Startseiteplayerrun") > -1) {
alert("You have the player open already !");
window.history.back();
} else {
//window.open("Startseiteplayerrun.html","_self");
link = document.createElement("a");
link.href = "Startseiteplayerrun.html";
//link.target = "_blank";
link.click()
;}});
</script><br>
<a href="index.html">home</a>
to check whether the string "Startseiteplayerrun" is present in the url bar.
However, this check only seems to happen after failing the first time => I'm able to open the frame once within itself:
Can this be mitigated ? The purposeof this "if else" is to not allow another iframe, if the urlbar contains "Startseiteplayerrun" ...
CodePudding user response:
If the string won't check right away, check if framed ~FIN~
<script>
if ( window.location !== window.parent.location ) {
alert("You have the player open already !");
window.history.back();
} else {
// The page is not in an iframe
}
</script>