Home >Web Front-end >JS Tutorial >js method to implement ifram to get the URL address of the parent window_javascript skills

js method to implement ifram to get the URL address of the parent window_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:15:002252browse

The example in this article describes the method of using js to implement ifram to obtain the URL address of the parent window. Share it with everyone for your reference. The specific implementation method is as follows:

var url='';
try { 
    url = window.top.document.referrer ; 
} catch(M) { 
    if (window.parent) { 
      try { 
        url = window.parent.document.referrer;
      } catch(L) { 
        url = "";
      } 
    } 
} 
if (url === "") { 
    url = document.referrer;
}

The above code has been executed in the browser and the address can be obtained.

I hope this article will be helpful to everyone’s JavaScript programming design.

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