forked from mbk-lab/rui_orig
2
0
Fork 0

Added OpenURL function to the Session interface

This commit is contained in:
Alexei Anoshenko 2022-08-19 14:28:49 +03:00
parent bcdbcd2628
commit 6a65f2a86b
1 changed files with 11 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package rui
import ( import (
"fmt" "fmt"
"net/url"
"strconv" "strconv"
"strings" "strings"
) )
@ -69,6 +70,8 @@ type Session interface {
DownloadFile(path string) DownloadFile(path string)
//DownloadFileData downloads (saves) on the client side a file with a specified name and specified content. //DownloadFileData downloads (saves) on the client side a file with a specified name and specified content.
DownloadFileData(filename string, data []byte) DownloadFileData(filename string, data []byte)
// OpenURL opens the url in the new browser tab
OpenURL(url string)
registerAnimation(props []AnimatedProperty) string registerAnimation(props []AnimatedProperty) string
@ -448,3 +451,11 @@ func (session *sessionData) SetTitleColor(color Color) {
func (session *sessionData) RemoteAddr() string { func (session *sessionData) RemoteAddr() string {
return session.brige.remoteAddr() return session.brige.remoteAddr()
} }
func (session *sessionData) OpenURL(urlStr string) {
if _, err := url.ParseRequestURI(urlStr); err != nil {
ErrorLog(err.Error())
return
}
session.runScript(`window.open("` + urlStr + `", "_blank");`)
}