Edge throws error "WebBrowser1.ExecWB is not a function"

Daley, Jeff (SNB) 21 Reputation points
2020-10-21T13:21:42.677+00:00

Hi,

I'm just wondering if ExecWB function been deprecated or if we have an Edge setting such as a security option disabled by our domain admins?

I have an ASP.net app that is being upgraded & our testing procedure includes Edge testing.

Our clients wanted both the browser's Page & Print Setup popups to automatically appear when activating the "Printable View" option (show a list/grid view in a new window that is printable).

We achieve this javascript.

function PrintIt(){
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(8, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
return false;
}

Code works fine from IE11 but the developer tool displays an error when testing with Edge, it throws "WebBrowser1.ExecWB is not a function".

I implemented a workaround where I establish the browser details & if its Edge, perform "window.print();" instead. Works fine. Since window.print() includes the page setup including "More Settings" & has an option to "Print using system dialog (Ctrl+Shift+P)", I believe our clients will approve the change.

Thanks, Jeff

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,314 questions
{count} votes

Accepted answer
  1. Yu Zhou-MSFT 13,256 Reputation points Microsoft Vendor
    2020-10-22T07:47:59.287+00:00

    Hi @Daley, Jeff (SNB) ,

    Are you testing this code on Edge Chromium? If so, I think it's an expected behavior.
    You're using the WebBrowser as an embedded ActiveX control but Edge Chromium doesn't support ActiveX control. Besides, it's an IE function and the new Edge is based on Chromium which has a completely different kernel with IE. So you can say it has been deprecated and can't be used on Edge.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Regards,
    Yu Zhou

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Daley, Jeff (SNB) 21 Reputation points
    2020-10-22T12:05:14.57+00:00

    Thanks Yu for clarifying.

    Yes, I'm testing on Edge Chromium.

    I didn't know the specifics like ActiveX not supported. I'll pass this onto my team.

    Sounds like my fix is the best alternative as we'll need to support both IE & Edge in the interim.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.