为 Web 视图 winjs 设置 cookie



所以我在我的地铁应用程序中使用x-ms-webview(使用HTML/JavaScript),并且需要启用/设置cookie。我尝试设置文档.cookie字段但没有成功。做同样事情的正确方法是什么?

var webview = element.querySelector("x-ms-webview");
var httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(
      Windows.Web.Http.HttpMethod.get,
      new Windows.Foundation.Uri("www.sample.com"));
// ... more settings
httpRequestMessage.headers.cookie.tryParseAdd("a=b;c=d;");
webview.navigateWithHttpRequestMessage(httpRequestMessage);

通常tryParseAdd(string)就足够了,转到 http://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.httprequestmessage.aspx了解更多信息。

最新更新