共用方式為


IBFCacheable::EnterBFCache method

Controls whether or not to suspend (cache) a page when navigating away in Internet Explorer 11 and later.

Syntax

HRESULT EnterBFCache();

Parameters

This method has no parameters.

Return value

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

EnterBFCache is called while suspending a page for caching. The developer should return S_OK if the suspend request was successful, thus guaranteeing not to initiate any tasks that should not be initiated on a suspended page. For example, if you return S_OK, you are guaranteeing that a webcam will not suddenly turn on, and sounds will not play.

Return a failure code if you cannot suspend or you cannot make this guarantee.

If you return S_OK, the page may still not be cached due to other factors (such as another ActiveX control that did not return S_OK). If you return a failure code, the page will not be cached.

There is no guarantee that a page that sees EnterBFCache will see ExitBFCache later. If Windows Internet Explorer elects to discard the cached page, the page will be closed while you are in EnterBFCache and your code still must not plays sounds, and so on.

Be aware that your control may, in some cases, continue to receive certain events from the system. Until EnterBFCache is called, your code must not play sounds play, cause a webcam to turn on, and so on.

Note  EnterBFCache will not be called twice in a row without a call to ExitBFCache in between.

 

Requirements

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Header

Mshtml.h

IDL

Mshtml.idl

Type library

Mshtml.dll

DLL

Mshtml.dll

IID

IID_IBFCacheable is defined as 30510861-98b5-11cf-bb82-00aa00bdce0b

See also

IBFCacheable