-
Notifications
You must be signed in to change notification settings - Fork 29.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: API to set URL of WebView #70339
Comments
(Experimental duplicate detection) |
Might be a duplicate of #65452 |
If we were to support this, would you expect:
|
We would expect an api to set the url and that navigation would work after the fact. |
As an example: if you load a url like
The two are are harder to support together for security reasons. We don't want to let webviews navigate to arbitrary pages and that content on that page could then use the vscode apis. Edit Just noticed you edited the comment so you can ignore these questions |
Yes, we would want to unblock navigation as part of this API request. *thanks for asking! |
In my scenario, webworkers of monaco don't seem to work in vscodes webviews. I would be fine with blocking navigation but persisting the URL query parameters which are then allowed to be updated from within the webview. |
@mjbvz support navigation is important for SPA, any plan to support this? |
I have managed to get a solution, available here, but it can't load js/css at this moment. |
Closing as this is not something we can provide a good story for Webviews take raw html in part because this lets us modify the html content before it is rendered, such as injecting the webview API. This is generally not possible for content loaded from a url (unless you have a proxy, but that's not business VS Code wants to get into). As a result, none of the VS Code variables or scripts would be available inside of a url based webview, which makes it about the same just rendering a full width+height iframe for the url inside your webview. Instead, if you need to display content from a specific url, use an iframe. You webview code can also post messages to this iframe to communicate with it |
I would like to revisit this issue. I'm having a bad time trying to implement a previewer for revealjs that doesn't lose its position each time it gets refreshed. In order to support this, revealjs updates its url to include the current slide number. @mjbvz you suggested to use an iframe in 2021, but that's not possible anymore since a couple of years at least (I tried and the iframe is always empty, my code is quite similar to #123766). The only way around this I see is some kind of convoluted message passing informing slide changes. |
Currently the webview API does not allow setting a URL to load content. Thus, if you want to load content from a remote/local server you need to set the webview's html to include an iframe.
Inserting an iframe inside of a webview breaks all keyboard shortcuts inside the webivew (so no copy / paste) and also outside of the webview (so you cannot open the command palatte)
The bugs described above do not occur when an iframe is not inserted within a webview. If we could set the webview's url we would not need an iframe. Thus the feature request is an extension of the webview api to set a url to load content.
The text was updated successfully, but these errors were encountered: