473,386 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to get meta tags content of parent page from an iframe using jQuery

85 64KB
Dear all..
I want to get the meta description and image in the head section of parent page from the iframe.

In a simple page I did it like this :
Expand|Select|Wrap|Line Numbers
  1.  <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
  2.     <title></title>
  3.      <link rel="image_src" href="source to my image" />
  4.     <script type="text/javascript">
  5.  
  6.         function addToInterest() {
  7.             var meta = document.getElementsByTagName("title")[0].innerHTML;
  8.             meta += "\n";
  9.             meta += $('meta[name=description]').attr("content");
  10.             meta += "\n";
  11.             meta += 
  12.             meta += $(location).attr('href');
  13.             meta += "\n";
  14.             meta += $('link[rel=image_src]').attr("href");
  15.             alert(meta);
  16.         }
  17.     </script>
  18.  
This works fine, but when inside an iframe, I want to get the title, location, meta descripton and the image of the parent page using jQuery.

For title and url of the parent page I have used:
Expand|Select|Wrap|Line Numbers
  1. var meta = parent.document.getElementsByTagName("title")[0].innerHTML;
  2. meta += document.referrer;
  3.  
its working fine also. but for the meta description and the image i am facing problem.
Any sample code for this please..


Regards,
Mudassir
Jul 4 '13 #1
3 5100
Frinavale
9,735 Expert Mod 8TB
I don't think you can access elements of an iframe from the parent page; likewise I don't think you can access elements of a parent page from the iframe.

I remember I was able to do something with cookies but that I felt it was a bit "hacky".

-Frinny
Jul 4 '13 #2
Mudassir
85 64KB
Frinny:

i get the title and url of the parent page from the iframe, i have mentioned it in the post.
i solved my problem by using Web User Control instead of iframe
:)

Regards:
Mudassir
Jul 5 '13 #3
Frinavale
9,735 Expert Mod 8TB
That is a good idea :)
It is good for search engine optimization not to use iframes :)

I'm glad you solved your problem.

-Frinny
Jul 9 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Day Bird Loft | last post by:
Web Authoring | Meta-Tags The first thing to understand in regard to Meta Tags is the three most important tags placed in the head of your html documents. They are the title, description, and...
1
by: Eric Levin | last post by:
I would like to load the Meta Tags in the page from Code: Currently they don't come up. The Source that I have: private void LoadHeaders() { DataSet oDs = new DataSet();
2
by: Jeronimo Bertran | last post by:
Hi, I have a page with a very data intensive grid which needs to be automatically refreshed constantly if a change is detected. In order to not refresh the complete page so often, I created an...
16
by: Edward | last post by:
Hi All, I am having huge problems with a very simple dotnet framework web page (www.gbab.net/ztest3.aspx) , it does NOT render correctly under Apple's Safari. The DIV's do not align amd float as...
9
The1corrupted
by: The1corrupted | last post by:
Alright, I have a meta tag and I'm working with frames, so I want the meta tag to target the good ol' "_parent" put when I put this code in.. <meta http-equiv='refresh' content='0;...
2
by: thetechturf.com | last post by:
I have some simple dynamic content pages (included below). I need to know how to add specific meta tags (ie. description, keywords, ect.), as well as extra specific header coding to a page. I would...
21
by: karen987 | last post by:
I have a news website, with asp pages. It has publishing software which allows you to add articles in a database, and then calls them up from links etc. I have added dynamic meta tags in 2 parts. The...
5
by: Candoer | last post by:
All I have the following meta tags on every page of my web site (www.candoer.org). Are they necessary on every page or only on the index page? <meta name="robot" content="noindex; nofollow">...
1
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.