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

  • SEARCH
  • Home
  • 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 786003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:58:06+00:00 2026-05-14T20:58:06+00:00

I am trying to display an HTML page with embedded JavaScript code inside a

  • 0

I am trying to display an HTML page with embedded JavaScript code inside a System.Windows.Forms.WebBrowser control. The JavaScript code is expected to interact with the embedding environment through the window.external object. Before invoking a method on window.external, JavaScript is supposed to check for the existance of the method. If it is not there, the code should invoke a generic fallback method.

// basic idea
if (typeof(window.external.MyMethod) != 'undefined') {
    window.external.MyMethod(args);
} else {
    window.external.Generic("MyMethod", args);
}

However, checking for a no-argument method with typeof seems to invoke the method already. That is, if MyMethod accepts any positive number of arguments, the code above will work perfectly; but, if MyMethod is a no-argument method, then the expression typeof(window.external.MyMethod) will not check for its type but invoke it, too.

Is there any work-around to this behavior? Can I somehow escape the expression window.external.MyMethod to prevent the method call from occurring?

  • 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-14T20:58:07+00:00Added an answer on May 14, 2026 at 8:58 pm

    I have not debugged your exact situation but I believe my psychic powers can work out what is going on here.

    The JScript language makes a distinction between use of a function and mere mention of it. When you say

    x = f;
    

    that says “assign a reference to the function identified by f to the variable x”. It mentions f. By contrast,

    x = f();
    

    uses f. It means “call the function identified by f and assign the returned value to x.”

    In short, functions in JScript are essentially what we would think of as properties of delegate type in C#.

    Some languages do not make this distinction. In VBScript, if you say x = f and f is a function, that means to call the function, same as x = f(). VBScript does not make a strong distinction syntactically between the use and mention of a function.

    The way this is all implemented is we use COM; specifically, we use OLE Automation. When dispatching a field of an object to get its value, the JScript engine passes flags that mean either “property get” or “method invoke”, depending on whether it was use or mention.

    But suppose your object being dispatched was written with the expectation that it would be called from VB. Perhaps it was written in VB. It is perfectly reasonable and legal for a VB object to say “oh, I see you’re asking me for the value of this method. Since I don’t understand the difference between mentioning a method and using it, I’ll just invoke it no matter which flag you pass”.

    I don’t know if there is a workaround, but I’d be willing to bet as much as a dollar that what’s happening is the invoked object is assuming that the caller wants VB semantics.

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

Sidebar

Related Questions

I am trying to display some JavaScript variable on my HTML page. I was
I'm trying to display the page title (html title) on the default.aspx page of
I'm trying to get an html page to display an XML file formatted with
I'm trying to display HTML source code in my NSDocument based application. However, it
I was trying to display a static html page in an android app having
I am trying to display images using an HTML page created by a servlet.
I'm trying to display an applet in an html page. I've had success doing
Using the Sinatra library, I'm trying to condense two functions that display HTML code
I'm trying to display a ≫ HTML entity in a page title, but they
I'm trying to display a page of html using bottle (the python web framework).

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.