JS如何获取iframe当前的url

PHPz
Release: 2020-09-04 16:04:36
Original
7197 people have browsed it

JS获取iframe当前的url的方法:可以通过【parent.document.getElementById("iframe_id").contentWindow.location.href】来获取。

JS如何获取iframe当前的url

JS如何获取iframe当前的url?

在许多时候我们在用iframe的时候都会做分页操作,iframe内部的url跳转将不能直接通过iframe的src属性来获得

iframe的当前url的获取方法

parent.document.getElementById("content_info").contentWindow.location.href
Copy after login

其中:content_info为iframe的id

具体示例:

/**获取iframe 的当前url
 * @param {Object} id iframe的id
 */
function getIframUrl(id){
	var url = parent.document.getElementById(id).contentWindow.location.href;
	return url;
}
Copy after login

推荐教程:javascript视频教程

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template