Home > Article > Web Front-end > top.location.href does not have permission. Solution_javascript skills
The same way, if someone saves my webpage, or includes it with an iframe, and then opens it, it will jump directly to my article page. The test was successful in the past, but today I saw a website including my page. I I thought it was okay if my homepage was iframed, but after clicking on the inner page, I found that I did not enter my website. I checked the javascript error message and found that it said "not authorized to access". After testing it locally, I found that the problem remained. It seems that the other website did not do it. What is the setting? It is a problem with my website. After troubleshooting step by step, I found that it is the problem of top.location.href. Most people on the Internet use the same method as mine. After searching for a long time, I finally found a solution:
If it is a cross-domain problem, just add the following sentence,
try{top.location.host}catch(exp){top.location=http://www.jb51.net;}