简体   繁体   中英

Send page by email, charset error

I'm having a slight painful error, currently I am creating a page in a new window using window.open().

var myWindow = window.open ('','','scrollbars=1, menubar=1, toolbar=1, titlebar=1, status=1,     resizable=1, width=800, height=600');

I then proceed to write out the HTML to the document.

I need to allow the user in IE9 to send the page I create using File->Send->Page by email. However when trying this the email is outputted using a weird charset.

格浴㹬਍†格慥㹤਍††琼瑩敬吾楨歮湩坧牯摬⁳慂敳䄠灰敬㱴琯瑩敬ാ †㰠敭慴栠瑴⵰煥極㵶䌢湯整瑮吭灹≥挠湯整瑮∽整瑸栯浴㭬挠慨獲瑥椽潳㠭㔸ⴹ∱ാഊഊ㰊䍓䥒呐䰠乁啇䝁㵅慊慶捓楲瑰ാ㰊ⴡഭഊऊ畦据楴湯猠瑥灵畆据楴湯愨

I have racked my brains and searched and searched on-line, I will appreciate any help anyone can give me.

Thanks Gary

UPDATE:

Just a quick update I am already setting the meta data for the page as the following.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

I'm having the exact same issue and I was able to partially solve it by explicitly setting the character set of the document. Here's my test page:

<HTML>
        <HEAD>
            <SCRIPT>
                var w = window.open();

                w.document.open();
                w.document.charset = 'utf-8';
                w.document.write('<html><head></head><body>Page 2</body></html>');
                w.document.close();
            </SCRIPT>
        </HEAD> 
        <BODY>
            Page 1
        </BODY>
</HTML>

The character set of the document starts out as "unicode" and wasn't changing no matter how I set the meta tags - only by explicitly changing the character set was I able to get clear text.

The problem now is that IE uses the wrong page! Even though I have the tab selected for page 2 the e-mail comes up with the content of page 1.

If I view the source or print the page I see the content for page 2. But if I save or e-mail the page I get the content for page 1.

I can save the content of page 2 if I change the save type to "Webpage, HTML only" but that's not the default so it will confuse people.

I'm assuming this is because the new tab still has the file name of the initial page - I'm trying to figure out if I can get the window to open with no connection to the initial page.

You can specify the encoding of a page explicitly by using the Content-Type header.

For example

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

specifies the content is in the Latin-1 alphabet used by most Western countries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM