"parent.document.title=" issue

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
wheatleyweb
Forum Newbie
Posts: 6
Joined: Wed Jan 14, 2009 11:02 am

"parent.document.title=" issue

Post by wheatleyweb »

Hello all,

First post here. I'm a noob to PHP and Javascript I'm vaguely familiar with. I have tried to implement simple PHP headers and footers for a current site I'm working on. Simple enough, I include both the header and footer on each content.php, works like a charm and will save me so much time and effort down the road when the client wants to add a new page to the site.

My problem... yes I know. I talk to much...

200+ pages. I've implemented free find search functionality to the site so users can search the site. However, the results always show the default title given in the header.php. I've used javascript on each of the content.phps in order to change the page title onload of the page.

Code: Select all

<script type="text/javascript">
void(parent.document.title='Title Title Title');
</script>
The problem lies when the user searches. The results all have the link labeled as the default header. The search results are correct, just doesn't look right when each page that returns from the search all have the same page title. How can I push the js above into the search results, so the results display the replaced title? Or is there a better way to work out this titling issue?

Thanks for your help on this one guys. As I delve more and more into PHP, I'm certain this forum will be a valuable resource for me.

wheatleyweb
wheatleyweb
Forum Newbie
Posts: 6
Joined: Wed Jan 14, 2009 11:02 am

Re: "parent.document.title=" issue

Post by wheatleyweb »

Any ideas guys? Am I not making sense?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: "parent.document.title=" issue

Post by VladSun »

Don't use JS to set page tittle - use PHP generated <title> tag in the head part.
There are 10 types of people in this world, those who understand binary and those who don't
wheatleyweb
Forum Newbie
Posts: 6
Joined: Wed Jan 14, 2009 11:02 am

Re: "parent.document.title=" issue

Post by wheatleyweb »

Hmm... Yes. Wrong tree I've been barking up. Thanks Vlad. I'll see what I can do to figure that out. I've been trying to teach myself PHP now for about a month. I understand the language fairly well. Now I just need to fully understand and envision applications.

I'm sure I'll be back on this one.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: "parent.document.title=" issue

Post by JAB Creations »

Using parent means you're likely interacting with frames...or found code that was intended for frames. VladSun is correct, you should just have PHP create the title (unless it's a static page, yuck!)

Though I now have to consider what you're doing to get around this Gecko bug for my site when you enable music...
https://bugzilla.mozilla.org/show_bug.cgi?id=264131
wheatleyweb
Forum Newbie
Posts: 6
Joined: Wed Jan 14, 2009 11:02 am

Re: "parent.document.title=" issue

Post by wheatleyweb »

Yeah.... No frames here. I suppose the code I found that I thought would fix my issue, was intended for a different app. I'm just confused on how to set up the base of the php site. I created headers and footers, and currently have them included on each of the content pages. However, links are just links to the content pages, for which grab the header and footer, on load.

I assume, at least it seems this way, that correct php design, has header and any other repeatable content, and the site replaces the "content" when called?

I need to figure this out. I'm going through a few online tuts (w3) to try and get a better grip of it all. Then I'm off to grab a few books.

Thanks for the help guys.
Post Reply