Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3970262
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:03:55+00:00 2026-05-20T04:03:55+00:00

I’m trying to port an extension from Firefox to IE. All the extension’s code

  • 0

I’m trying to port an extension from Firefox to IE. All the extension’s code is in JS (no C++ components), so I figured I would reuse the code and only trouble myself with the mozilla specific parts of it (which is no doubt a torture too, but I think it’s less painful than rewriting it from the scratch).

The FF extension is wrapped in a JS object that gets initialized during the “load” event. The “business” code of the extension is then fired on “DOMContentLoaded” event.

My original plan was to create a WSC (Window Scripting Component) and listen for onLoad event there and basically do the same thing that the original code does. However, I found out there’s no implicit global window object in my JavaScript scripting component,

My plan B was to listen for the “onBeforeNavigate2” event in my C++ BHO code and call the JS WSC code that handles the extension object initialization there. So I decided to pass the browser window object as a “window” parameter to the onBeforeNavigate JS function and rewrite the original extension code to be using the explicit “window” variable instead of relying on the implicit global object.

However, when I handle the “OnDocumentComplete” event (once again listening for it in the BHO and passing the browser window object as an argument to a JS function in the WSC), I get a “Can’t execute code from a freed script” error.

The WSC code looks like this:

<?xml version="1.0"?>
<component>
<registration
   ...
>
</registration>
<public>
 <method name="OnBeforeNavigate">
   <parameter name="win" />
 </method>
 <method name="OnDocumentComplete">
   <parameter name="win" />
 </method>
</public>
<script src="sharedjs/foo.js" />
<script language="JScript">
<![CDATA[

var window;

function OnBeforeNavigate(win)
{
   window = win.document.parentWindow.top;
   window.myNS.extObject = initExtensionObject(...);
}
function OnDocumentComplete(win)
{
   window = win.document.parentWindow.top;
   var obj = window.myNS.extObject;
   obj.doTheBusinessStuff();
}
]]>
</script>
</component>

I assume that’s because the WSC is unloaded after the handler function returns. However, there is a reference to the JS extension object kept in the browser window object, so I would expect the browser to keep the code.

So – what’s my mistake here, please?

Cheers,
Tom

PS: WSC stands for Windows Scripting Component

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:03:55+00:00Added an answer on May 20, 2026 at 4:03 am

    It sounds like your reference to the window object is no longer valid when the JS finally executes – What causes the error "Can't execute code from a freed script"

    A couple of things you could try:

    instead of win.document.parentWindow.top, just use win.document.parentWindow which should point to a valid window reference. As where “top” could point to a parent frame or window and you end up with one of the causes in the provided link.

    Check to make sure the reference to myNS.extObject isn’t being destroyed in the bho. You should probably try catch each statement in OnDocumentComplete because either could be giving you the error you’re seeing and both have different resolutions.

    Finally, if you can, execute the extension using the Context Menu in IE – http://msdn.microsoft.com/en-us/library/bb735853(v=vs.85).aspx

    Then you would have access to the window object via the external.menuArguments object in javascript land.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.