Js code to prevent the login page from appearing in the frame

  • 2020-03-30 03:36:40
  • OfStack

So when you're doing nested development with the frame page, when you restart the server, the login page will appear in the frame page,

Therefore, we need to use js to judge the current address information in the login page, and then jump to a separate page for login.

Js code is as follows:


$("document").ready(function(){ 
//Prevent the login page from appearing inside the frame
if(top.location!==self.location){ 
//alert(top.location); 
//alert(self.location); 
top.location.href=self.location.href; 
} 
});

Related articles: