Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can i change the title in a popup window 1

Status
Not open for further replies.

mit99mh

Programmer
Sep 24, 2002
246
GB
i need to display word, .txt documents in new popup windows in IE5 but i want the virtual file path removing eg is currently displayed but I want eg LIBRARY ITEM to be displayed to replace the URL.

I thought it could simply be done using the code below but this errors in IE5 and doesn't work (although strangely the code did work when using the browse on Homesite). Any help would be greatly appreciated.

<script language=&quot;JavaScript&quot;>
<!--
function open_popup(page) {
var myWindow = window.open(page,&quot;test&quot;,&quot;width=200,height=200&quot;);
myWindow.document.title = &quot;testpage&quot;;
return false;
}
-->
</script>

<p>
<a href=&quot;#&quot; onClick=&quot;return open_popup('index.html');&quot;>Open Popup</a>
</p>
 
I don't know the answer but I tried a few variations on your script and thought you might like to know what I found.

1. Loading a Word document in place of index.html does indeed cause an error, &quot;member not found&quot; for the statement that is intended to change the title. I don't get a browser window at all, I get a window with the Word application in it. So it seems reasonable that the title in that window could not be changed with a statement referring to a browser window.

The Word application window does not open at all for my Netscape, instead I get the download dialog. This probably is due to the way my computer is configured.

2. Loading an HTML document does not cause any error in IE5 nor in N4.7 nor N6.2. And the title is changed from the <TITLE></TITLE> coded in the document to the one I use in the script. This worked with no error in IE5 but not at all in Netscape. My DOM reference book states that document.title is scriptable for N2 and IE3 and later so this is a puzzle, why it is not working in my Netscape.

3. Again your script works for me when loading an HTML page. However, you may want to know that the onclick event handler does not use the true/false values you are returning. The script works just fine without the return statements.

4. Finally I found that the URL appears in the title only when there is no title tag in the HTML document. And only in IE, not in Netscape.

Maybe someone out there has the answer.
 
I got this sorted out:

1.Solution create a frameset page

<HTML>
<title>TESTING<</title>
<FRAMESET COLS=&quot;100%&quot;>
<FRAME SRC=&quot;&quot; name=&quot;page&quot;>
<\/FRAMESET>
</HTML>

2.In mainpage open the frameset

<script language=&quot;JavaScript&quot;>
<!--
function open_popup(frame) {
var myWindow = window.open(frame,&quot;test&quot;,&quot;width=200,height=200&quot;);

if (myWindow.opener == null)
myWindow.opener = self;

myWindow.page.location.href=&quot;database_model.doc&quot;;

}
-->
</script>

<p>
<a href=&quot;#&quot; onClick=&quot;return open_popup('frame.html');&quot;>Open Popup</a>
</p>

3. Set the frame content to the document and the title is whatever you set it as in the frameset

 
Good job. That works for me, although I could not get it to work in Netscape. But I don't think anyone is using Netscape anymore anyway.

Here is a little variation that might be easier to use if you have links to several documents.

It takes several seconds for Word to load a document on my computer so the title in the frameset should be nice.
Code:
<html>
<head>
	<title>Title We See Until Document Loads</title>
</head>

<FRAMESET COLS=&quot;100%&quot;>
<FRAME SRC=&quot;&quot; name=&quot;frameIt&quot;>
</FRAMESET>

</html>


Here I pass the document URL and the title I want to use to the function.
Code:
<html>
<head>
	<title>Name that Window!</title>
</head>

<body>
<script language=&quot;JavaScript&quot;>
<!--
function open_popup(docuDrama, nameIt) {
	var myWindow = window.open('wrapItUp.html',&quot;docuView&quot;,&quot;width=200,height=200&quot;);
    
    if (myWindow.opener == null)
           myWindow.opener = self;
        
    myWindow.frameIt.location.href = docuDrama;
	myWindow.document.title = nameIt;
}
 -->
</script>

<p>
<a href=&quot;#&quot; onClick=&quot;open_popup('VCRGuide.doc', 'How to Use Your VCR');&quot;>Open Popup</a>
</p>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top