Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 970
  • Last Modified:

change the title tag of a web page dynamically?

Hi Experts,

How can I change the Title tag of a web page dynamically using server side code?

Also I was trying to do it using javaScript from within a frame i.e. parent.document.title = 'bla'. But I was inside a user control.

How can I call a javaScript function when my user control is finished loading?

thanks a lot
0
kateL
Asked:
kateL
1 Solution
 
skiltzCommented:
When a page loads you can change the title like page.title = "My new title"
0
 
kateLAuthor Commented:
Hmmm but not do I set the title when I am inside a user control that is a part of a web page that is in a frame?

It's really the web page that contains the frames who's title I want to change
0
 
joshbmCommented:
You want the frame to control the frameset's <title> tag?  Be sure that your <head> is <head runat="server"> on the frameset page and then you should be able to do:

Page.Title = "Your Page Title";

If you want to control the <title> in the frameset page, you could use JavaScript.  Unless you need it hard-coded for SEO purposes.  The way you would do that is in your <head> section of your frame page you could put:

<script type="text/javascript">
parent.document.title = document.title;
</script>

For example, without using ASP.NET, you could do it simply using JavaScript:
===================
frame.html
===================
<html>
<head>
<title>Change the Title here!</title>
<script type="text/javascript">
parent.document.title = document.title;
</script>
</head>
<body>

</body>
</html>
===================

===================
frameset.html
===================
<HTML>
<HEAD>
<TITLE>This is a frameset, the title will be replaced.</TITLE>
</HEAD>
<FRAMESET>
    <FRAME src="frame.html"  />
</FRAMESET>
</HTML>
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now