Internet Explorer and blocking Javascript

18:18
if you are using TWebBrowser, you need to override the invoke method for
TOleControl.Check the code Below:

interface
 
TOleControl2 = class(TOleControl, IDispatch)
private
FScript: boolean;
protected
function IDispatch.Invoke = Invoke;
function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult;
stdcall;
public
constructor Create(AOwner: TComponent); override;
published
property ScriptEnabled: boolean read FScript write FScript;
end;
 
implementation
 
 
{ TOleControl2 }
 
constructor TOleControl2.Create(AOwner: TComponent);
begin
inherited;
FScript := true;
end;
 
 
 
function TOleControl2.Invoke(DispID: Integer; const IID: TGUID; LocaleID:
Integer; Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer):
HResult;
const
DISPID_AMBIENT_DLCONTROL = -5512;
DLCTL_DLIMAGES = $00000010;
DLCTL_NO_SCRIPTS = $00000080;
DLCTL_NO_JAVA = $00000100;
DLCTL_NO_RUNACTIVEXCTLS = $00000200;
DLCTL_NO_DLACTIVEXCTLS = $00000400;
DLCTL_DOWNLOADONLY = $00000800;
 
var
F: TFont;
begin
if (Flags and DISPATCH_PROPERTYGET <> 0) and (VarResult <> nil) then
begin
Result := S_OK;
case DispID of
DISPID_AMBIENT_BACKCOLOR:
PVariant(VarResult)^ := Color;
 
DISPID_AMBIENT_DISPLAYNAME:
PVariant(VarResult)^ := StringToVarOleStr(Name);
 
DISPID_AMBIENT_FONT:
begin
if (Parent <> nil) and ParentFont then
F := TOleControlHack(Parent).Font
else
F := Font;
PVariant(VarResult)^ := FontToOleFont(F);
end;
 
DISPID_AMBIENT_FORECOLOR:
PVariant(VarResult)^ := Font.Color;
 
DISPID_AMBIENT_LOCALEID:
PVariant(VarResult)^ := Integer(GetUserDefaultLCID);
 
DISPID_AMBIENT_MESSAGEREFLECT:
PVariant(VarResult)^ := True;
 
DISPID_AMBIENT_USERMODE:
PVariant(VarResult)^ := not (csDesigning in ComponentState);
 
DISPID_AMBIENT_UIDEAD:
PVariant(VarResult)^ := csDesigning in ComponentState;
 
DISPID_AMBIENT_SHOWGRABHANDLES:
PVariant(VarResult)^ := False;
 
DISPID_AMBIENT_SHOWHATCHING:
PVariant(VarResult)^ := False;
 
DISPID_AMBIENT_SUPPORTSMNEMONICS:
PVariant(VarResult)^ := True;
 
DISPID_AMBIENT_DLCONTROL:
if not (FScript) then
begin
PVariant(VarResult)^ := Integer(DLCTL_NO_JAVA or
DLCTL_NO_SCRIPTS or DLCTL_DLIMAGES);
//PVariant(VarResult)^ := Integer(DLCTL_DOWNLOADONLY or
DLCTL_NO_JAVA or DLCTL_NO_SCRIPTS or DLCTL_NO_DLACTIVEXCTLS or
DLCTL_NO_RUNACTIVEXCTLS or 0);
end;
DISPID_AMBIENT_AUTOCLIP:
PVariant(VarResult)^ := True;
else
Result := DISP_E_MEMBERNOTFOUND;
end;
end else
Result := DISP_E_MEMBERNOTFOUND;
end;





Hope this helps

Fitim