Home > Mobile >  URL check only works on second time within iframe
URL check only works on second time within iframe

Time:01-31

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:

frame can be opened once b4 script properly recognizes url string and

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>
  • Related