[英]Get meta tags of parent from iframe using jQuery/Javascript
I have an HTML file with the following content 我有一个包含以下内容的HTML文件
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" name="viewport">
<meta content="desc goes here" name="description">
<meta content="auth name" name="author">
<title>builder 1.0</title>
</head>
<body>
<iframe width="100%" height="100%" src="http://domain.com/a.html" name="cxsideframe" scrolling:'no';="" id="frame1" style="overflow:hidden;">
</iframe>
</body></html>
The content of a.html is a.html的内容是
<html>
<head>
<meta charset="utf-8">
<title>builder v1.0</title>
<body>
<img src="http://example.com/images/01._V397411194_.png" style="display:none" alt=""/>
<img src="http://example.com/images/V386942464_.gif" style="display:none" alt="" />
</body></html>
I need to know a method to get the contents of meta tags and image lists of parent page html from the parent page using jQuery or javascript. 我需要知道一种使用jQuery或javascript从父页面获取meta标签和父页面html图像列表的内容的方法。
$('meta[name=author]').attr("content"); does not work for me
You can use document.getElementsByTagNames, and then manipulate the array returned 您可以使用document.getElementsByTagNames,然后处理返回的数组
var metas = document.getElementsByTagName("meta");
var imagesOnPage = document.getElementsByTagName("img")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.