Home >Web Front-end >JS Tutorial >top.location.href does not have permission. Solution_javascript skills

top.location.href does not have permission. Solution_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:02:141166browse

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;}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn