예제 #1
0
파일: webview.go 프로젝트: joy999/walk
func (wv *WebView) SetURLWithPost(url string, postData netUrl.Values) error {
	return wv.withWebBrowser2(func(webBrowser2 *win.IWebBrowser2) error {
		urlBstr := win.StringToVariantBSTR(url)
		flags := win.IntToVariantI4(0)
		targetFrameName := win.StringToVariantBSTR("_self")

		postStr := ""

		for k, v := range postData {
			if len(v) == 1 {
				postStr += k + "=" + netUrl.QueryEscape(v[0]) + "&"
			} else {
				for i, _v := range v {
					postStr += k + "[" + strconv.Itoa(i) + "]=" + netUrl.QueryEscape(_v) + "&"
				}
			}
		}

		postStr = postStr[:len(postStr)-1]

		postBstr := unsafe.Pointer(win.StringToVariantBSTR(postStr))

		if hr := webBrowser2.Navigate2(urlBstr, flags, targetFrameName, postBstr, nil); win.FAILED(hr) {
			return errorFromHRESULT("IWebBrowser2.Navigate2", hr)
		}

		return nil
	})
}
예제 #2
0
파일: webview.go 프로젝트: joy999/walk
func (wv *WebView) SetURL(url string) error {
	return wv.withWebBrowser2(func(webBrowser2 *win.IWebBrowser2) error {
		urlBstr := win.StringToVariantBSTR(url)
		flags := win.IntToVariantI4(0)
		targetFrameName := win.StringToVariantBSTR("_self")

		if hr := webBrowser2.Navigate2(urlBstr, flags, targetFrameName, nil, nil); win.FAILED(hr) {
			return errorFromHRESULT("IWebBrowser2.Navigate2", hr)
		}

		return nil
	})
}