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?
2 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>
2 Comments
Windows.open' create in another window, but WebView` it self is just one. What you are wanting is to change the server side feature.I am going to assume that you want to navigate to another page in the current window, instead of a popup. Here is something that should be helpful. https://learn.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/web-view#navigating-to-content