SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing Browser Title

    Right now I have a web page that loads two frames, a top frame that always stays the same (it displays a banner ad along with some search engine text) and a bottom frame which displays a different web page every time. I'd somehow like to set it up so the title displayed in the browser is the title of the html page shown in the second frame. Does anyone know how to do this, I assume with Javascript.

    Thanks

    Matt
    Internet Consultant with 8 Years Experience
    Business Idea/Partnerships contact me, m@zii.com
    AIM: MattFS218 / ICQ: 5138409

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    northern Maine
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    top.document.title=document.title;
    Jason - Contact Me
    Supermoderator @ CodingForums

  3. #3
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hrm...I can't seam to get it to work....maybe I didn't explain my situation clearly enough

    I setup a test url at
    http://64.75.41.201/test.html

    I want the document title to be "Yahoo!" (the <title> of the bottom frame).

    If the bottom fram always changes .... how can I set the title of the web browser to the title of the bottom frame?

    Thanks in advance.

    Matt
    Internet Consultant with 8 Years Experience
    Business Idea/Partnerships contact me, m@zii.com
    AIM: MattFS218 / ICQ: 5138409

  4. #4
    SitePoint Enthusiast Rips's Avatar
    Join Date
    Mar 2001
    Location
    London, UK
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yo,

    Jkd's solution won't work because document.title is a read-only property.

    So I figured you'd need to have some JavaScript execute inbetween the <title> and </title> tags that writes the frames[1].document.title property. Except this doesn't work, the code doesn't get executed, just displayed as the title. Doh!

    Anyone think of anything else? This should be simple! Heh.

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    northern Maine
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.title is mutable in IE4+/NS6. Try it, save this file onto your hard drive and view it:

    Code:
    <html>
    	<head>
    		<title>Original Title</title>
    	</head>
    	<body>
    		<a href="#" onclick="document.title='Overwritten title';return true">Click to Change Document's Title</a>
    	</body>
    </html>
    It works fine.
    Jason - Contact Me
    Supermoderator @ CodingForums

  6. #6
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    As jkd implied and Rips discovered, Netscape 4+ doesn't allow you to change the document's title. If you would like more information, see "The Title Property" snippet at my site.
    Insofar as your problem, your only solution may be to reverse your frames so that the static frame is on the bottom.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  7. #7
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, so why does this not work.



    <HTML>
    <FRAMESET FRAMEBORDER=0 FRAMESPACING=0 BORDER=0 ROWS="50,*">
    <FRAME SRC="http://www.infoseek.com">
    <FRAME SRC="http://www.yahoo.com" onLoad="document.title=frames[1].document.title;return true">
    <NOFRAMES>
    <BODY>
    non frames
    </BODY>
    </NOFRAMES>
    </FRAMESET>
    </HTML>

    If i do an onLoad="document.title='dsfsdfsd';return true"
    I can get dsfsdfsd as the title...but not the Yahoo! title.

    Matt
    Internet Consultant with 8 Years Experience
    Business Idea/Partnerships contact me, m@zii.com
    AIM: MattFS218 / ICQ: 5138409

  8. #8
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you referencing the correct frame? The [1] indicates that you are actually referencing the 2nd frame. Javascript starts its counting from [0].
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  9. #9
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Matt,

    Does the phrase "Access is denied" ring a bell? If you put an alert in the onLoad (alert(document.title)) you will see a blank. If you add a title to your page <title>test</title> the alert will display 'test' -- anything else comes up with the access message. The implication? -- you do not have rights to put someone else's title on your page -- offhand, I would say that is a good thing.

    Creole: his numbering is correct since he is attempting to assign yahoo's title (frame[1]) to the entire document.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  10. #10
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Vincent,

    Thanks for your help. If I reversed the frames (put the static page on bottom), is it possible to accomplish what I'm trying to do? Or is there a way to go out and manually parse the document for the <title> flag?
    Internet Consultant with 8 Years Experience
    Business Idea/Partnerships contact me, m@zii.com
    AIM: MattFS218 / ICQ: 5138409


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •