document.title in IE
Discussion
Before I pull my hair out is there something I don't know about IE? (The answer to that is lots!)
I'm trying to set the page title of a user initiated popup which displays a gif image and it's not working, what am I missing?
I call this simple function
{{{
function popWindow() {
ElementWindow = window.open('images/print-bg.gif', 'popWin','width=680, height=550, resizable=0, menubar=0, toolbar=0');
document.title = "How To Print Background Colours";
}
}}}
From here
The window opens with the options I've set, but the page title remains as the location. It's on an intranet and will only ever be opened with IE so there are no issues with any other browsers.
I know I'm doing something stupid here
I'm trying to set the page title of a user initiated popup which displays a gif image and it's not working, what am I missing?
I call this simple function
{{{
function popWindow() {
ElementWindow = window.open('images/print-bg.gif', 'popWin','width=680, height=550, resizable=0, menubar=0, toolbar=0');
document.title = "How To Print Background Colours";
}
}}}
From here
please click <a href=\"javascript:popWindow()\"><strong>here</a>
The window opens with the options I've set, but the page title remains as the location. It's on an intranet and will only ever be opened with IE so there are no issues with any other browsers.
I know I'm doing something stupid here

Bluequay said:
Are you changing the title of the main window? Shouldn't it be something along the lines of ElementWindow.document.Title = 'sfsds'
Whoops, the parent window is changing. Told you I was doing something stupid 
I too thought it should be:
ElementWindow.document.title = "How To Print Background Colours";
But I get a JS error

They get a description, I haven't included all the code. Decoration is set to none in the css as an aside 
I don't want to include it in a page of it's own as that would mean maintaining it (and various others when I've done) when it's not really necessary. The link is to an animated gif that shows the end user visually how to enable background colour printing. If I can do this I can reuse that code instead of writing pages.

I don't want to include it in a page of it's own as that would mean maintaining it (and various others when I've done) when it's not really necessary. The link is to an animated gif that shows the end user visually how to enable background colour printing. If I can do this I can reuse that code instead of writing pages.
4hero said:
It may well work although it isn't the look I really want. That said that's a superb link and I'm sure I'll put it to good use at some point. Thanks I just want an animated gif (It's a screen cap of running through changing a printer setting) in a window with a suitable title and the bare minimum of clutter.
When I change the code to what I think should run as it is below I get "unspecified error".
document.title = "How To Print Background Colours"; must be syntactically correct as it alters the parent window's title, but as soon as I precede it with elementWindow it spits an error. To my mind I'm not referencing the child window correctly but I can't see why.
{{{
function popWindow() {
elementWindow = window.open('images/print-bg.gif', 'popWin','width=680, height=550, resizable=0, menubar=0, toolbar=0');
elementWindow.document.title = "How To Print Background Colours";
}
}}}
When I change the code to what I think should run as it is below I get "unspecified error".
document.title = "How To Print Background Colours"; must be syntactically correct as it alters the parent window's title, but as soon as I precede it with elementWindow it spits an error. To my mind I'm not referencing the child window correctly but I can't see why.
{{{
function popWindow() {
elementWindow = window.open('images/print-bg.gif', 'popWin','width=680, height=550, resizable=0, menubar=0, toolbar=0');
elementWindow.document.title = "How To Print Background Colours";
}
}}}
The problem is 'document.title' refers to the HTML <title> element. As you're just loading a gif there is no 'document' or 'title' to reference.
So AFAIK you can't do it this way without using one of the myriad lightbox plugins, or placing the image in some containing HTML as suggested above.
Though on this note you could try something along the lines of:
function popWindow() {
elementWindow = window.open('blank.htm', 'popWin','width=680, height=550, resizable=0, menubar=0, toolbar=0');
elementWindow.document.write = "<html><head><title>How To Print Background Colours</title></head><body><img src="images/print-bg.gif" /></body></html>";
}
Where 'blank.htm' is a physical empty text document.
Disclaimer: I have not tested this!
So AFAIK you can't do it this way without using one of the myriad lightbox plugins, or placing the image in some containing HTML as suggested above.
Though on this note you could try something along the lines of:
function popWindow() {
elementWindow = window.open('blank.htm', 'popWin','width=680, height=550, resizable=0, menubar=0, toolbar=0');
elementWindow.document.write = "<html><head><title>How To Print Background Colours</title></head><body><img src="images/print-bg.gif" /></body></html>";
}
Where 'blank.htm' is a physical empty text document.
Disclaimer: I have not tested this!
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff



Could it be as simple as 'ElementWindow' is a variable and JS doesn't allow variables beginning with a capital letter?

