Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2010
    Location
    Far far away
    Posts
    122
    Thanks
    0
    Thanked 16 Times in 16 Posts

    JScript: 'htmlfile: Catastrophic failure' error

    I have encountered unpleasant thing.

    Code:
    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).

    Code:
    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?

  • #2
    Regular Coder
    Join Date
    Sep 2010
    Location
    Far far away
    Posts
    122
    Thanks
    0
    Thanked 16 Times in 16 Posts
    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
    Code:
    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';


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •