...

View Full Version : JScript: 'htmlfile: Catastrophic failure' error



siberia-man
12-25-2010, 02:29 PM
I have encountered unpleasant thing.



var htmlfile = new ActiveXObject('htmlfile');

var window = htmlfile.parentWindow;
var document = window.document;

var tag = document.createElement('textarea');
tag.innerHTML = 'any non-empty string';


The example above in JScript environment throws the following exception
htmlfile: Catastrophic failure

Any script (JS or VBS) is down when assign the 'innerHTML' property of tags. In these examples I create the TEXTAREA tag but it does not matter. This don't work for ALL block or inline tags. Nevertheless an assignment of the 'innerHTML' property in browsers works fine (see the second example).



var tag = document.createElement('textarea');
tag.innerHTML = 'any non-empty string';


I have a question. Is this known bug or feature of the 'htmlfile' object? Or maybe someone of you has encountered this?

siberia-man
12-25-2010, 03:14 PM
Good news. I found an answer for my question. I need additionally initialize the document. Just browsers make this automatically but we should make this manually


var htmlfile = new ActiveXObject('htmlfile');

var window = htmlfile.parentWindow;
var document = window.document;
document.open(); // mandatory !!!
document.close(); // optional

var tag = document.createElement('textarea');
tag.innerHTML = 'any non-empty string';



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum