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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup Window Doesn't Use The Specified Meta Charset

Status
Not open for further replies.

KJJones

Technical User
Feb 2, 2007
3
US
Hello,

I am having difficulty with character sets in a new child window opened by a Javascript function. Though the meta content-type tag is set just like in the parent window, the child window charset reverts to the browser default. The meta tag setting shows in the child-window source and in the firefox page info for the child-window, but it doesn't affect the browser setting for that window. I assume the browser is ignoring the meta tag, but I don't know why..

One page affected is at
Just click the vocabulary list button, and then compare the charset in each window.

It runs on the following code:
Code:
var vocabWin=window.open('',"_blank","menubar=no,width=400,height=600,scrollbars=yes,resizable=yes");
var listStr="foreign language vocabulary goes here";
var charset="<?php echo $charset; ?>";  
vocabWin.document.open();
  vocabWin.document.write('<html>');
  vocabWin.document.write('<head><meta http-equiv="Content-Type" content="text/html; charset=');
  vocabWin.document.write(charset);
  vocabWin.document.write('">');
  vocabWin.document.write('<title>Vocabulary List</title>');
  vocabWin.document.writeln('</head><body>');

//vocabulary list stuff clipped

vocabWin.document.write('</body></html>');
vocabWin.document.close();

Verbose, I know. I hope to concat the whole thing into one simple string, and write that to the window at once. Is document.write() the problem? Why is the meta tag being ignored by the browser?

Thanks for any help,
-Kevin
 
I saw the same charset type in the main window and the child window: iso-8859-1

<.

 
I saw the same charset type in the main window and the child window: iso-8859-1"

Thanks for taking a look. Is that your browser's default charset? Mine is set to UTF-8, and that's the charset that shows up in the child window, though not the parent window, in both Firefox and IE.

-Kevin
 
Yeah, it was my default.

Do you have a meta tag on your initial page that sets it? If so, that will override any default settings.


<.

 
Do you have a meta tag on your initial page that sets it? If so, that will override any default settings. "

Yes, here's the main page's first few lines:

Code:
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Semi-Fluent.com Spanish Language Study Tool</title>
</head>

So the child window is supposed to inherit from the parent window? Perhaps my window.open settings are making the new window an independent, and not really a child window.

Thanks again, I'll mess around a bit more.
-Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top