Question The Character Encoding Of The Html Document Was Not Declared.

Potish

Member
I have a website that redirects a user to a external host for payment processing. When the user is returned to my website depending on the results of the payment processing I need to redirect the user to a final webpage with POST method so their order can be completed. I call the javascript code below to execute the POST and it works on Chrome and Opera browsers. Howver on Firefox and IE browsers it fails and the user ends up with a blank page. The error on the page is given as follows

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.

The Javascript looks as follows

Code:
var cSecurem = 'https://www.website.com/';

function gotofinalpage(p1,p2) {
    setLoginCookie('secure');
    var cURL = cSecurem + 'bh/finalpage.r?';
    var myForm = document.createElement("form");
    myForm.method="post" ;
    myForm.action = cURL ;

    var param1   = document.createElement("input");   
    param1.type  = "text";
    param1.name  = "p1";   
    param1.value = p1;
    myForm.appendChild(param1);   

    var param2   = document.createElement("input");   
    param2.type  = "text";
    param2.name  = "p2";   
    param2.value = p2;
    myForm.appendChild(param2);

    myForm.submit() ;
}

I have found several articles that note that adding code below to the html document error should fix the problem but this has not worked for me.

Code:
<meta content="utf-8" http-equiv="encoding"/>

Any ideas why this error would occur on Firefox and any suggestions on how I could fix it.

 

lee.bourne

Member
Is this page a webspeed created one? If so, have you tried including the character encoding in the output-header section of your webspeed?

e.g. Content-Type: text/html; charset=utf-8
or
Content-Type: text/html; charset=iso-8891-1
 

Potish

Member
Is this page a webspeed created one? If so, have you tried including the character encoding in the output-header section of your webspeed?

e.g. Content-Type: text/html; charset=utf-8
or
Content-Type: text/html; charset=iso-8891-1

Thank you for the suggestion. Yes the page is created with webspeed. I did have the content type set to
output-content-type("text/html":U).

I went ahead and updated it to
output-content-type("text/html~;charset=utf-8":U).

which did help because the error reported earlier no longer comes up. However there is still a problem because he page comes to a stop with no errors and so I am trying to figure out what the new problem is now. Same as before code works on Chrome and Opera but fails on Firefox and IE.
 
Thank you for the suggestion. Yes the page is created with webspeed. I did have the content type set to
output-content-type("text/html":U).

I went ahead and updated it to
output-content-type("text/html~;charset=utf-8":U).

which did help because the error reported earlier no longer comes up. However there is still a problem because he page comes to a stop with no errors and so I am trying to figure out what the new problem is now. Same as before code works on Chrome and Opera but fails on Firefox and IE.
How about setting the form charset? HTML DOM Form acceptCharset Property
 
Top