Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling window.open JavaScript in WebView

I have a WebView in an UWP app. The page shows a popup window by calling window.open (https://www.w3schools.com/jsref/met_win_open.asp). Is there a way for me to make this open in the WebView?

like image 403
Green Train Avatar asked Sep 17 '25 06:09

Green Train


1 Answers

Is there a way for me to make this open in the WebView?

The open() method creates a new secondary browser window. If you want the new page to open also inside the WebView means that you don't want to create a new secondary browser window but navigate to another page in current window.

In that case, you could use window.location instead of window.open. For example:

<html>
<head>
    <script type="text/javascript">
        function open_win() {
            //window.open("http://www.microsoft.com")
            window.location = "http://www.microsoft.com"
        }
    </script>
</head>

<body>
    <form>
        <input type=button value="navigate to" onclick="open_win()">
    </form>
</body>
</html>
like image 103
Sunteen Wu Avatar answered Sep 18 '25 20:09

Sunteen Wu