Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

html - How to change window title from a frame in javascript?

I hosted my web app on a freehoster service which shows my webpage in a frameset. 2 frames are there. In the top narrow frame there are their ad and the bottom frame is mine. I can set the title in the admin panel but it always remains the same regardless what is in my title tag. Setting document.title in javascript not works. But if I break out from the frameset using the ff's This frame/show option it will change the window/tab title as expected.

So is it possible to change the parent document's title from my frame?

(background: it will be an ajax board game and I want to notify the user somehow when it's his turn.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, but it has to be on the same domain (and use a relative url for a path)

  window.parent.document.title = "Your new title";

If the iframe/frame is on a different domain, then you'll get a permission denied error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...