Page title.
Moderator: General Moderators
Page title.
Hi, I was wondering how do I get the page title in javascript? You know the page title with in the <title> brackets. Is there a JavaScript property for this, that I could modify and what not?
Thanks for reading.
Thanks for reading.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Great! Now all I need to know is how I can place the value of a iframe's document title...Kieran Huggins wrote:document.title is read/write, as far as I know.
EDIT: For example, Google Video has an iframe, but how do they get the document's title the title of the iframe?
Awesome! But how do I get the object of the frame?VladSun wrote:DOM iframe
I tried:
Code: Select all
alert(document.getElementById("3rdPartyFrame").title);
EDIT: I believe this is because of the Same Origin Policy. I can't access the properties or methods of an iframe with the src or like, yahoo or something.
How does google do it?
Probably your iframe source address and the address of the page itself are not in the same domain. So, I don't think you can do this because it is Cross Site Scripting and it is considered to be a security issue.
PS: you are trying to read the wrong title - it is the hint when user puts his mouse over the iframe...
PS: you are trying to read the wrong title - it is the hint when user puts his mouse over the iframe...
There are 10 types of people in this world, those who understand binary and those who don't
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
A frame is a window, you need to access the frame's document object.
check out: http://jennifermadden.com/javascript/frame.html for some example code
Code: Select all
parent.yourFrameName.document.titleThe problem is, the loaded web page in the frame is yahoo.com's homepage. If I where to access yahoo's dom, it would be considered cross scripting. I think this is illegal in the web at the moment, right?Kieran Huggins wrote:A frame is a window, you need to access the frame's document object.check out: http://jennifermadden.com/javascript/frame.html for some example codeCode: Select all
parent.yourFrameName.document.title