How to clear the content of a webview?
I've tried with weburl.url = 'about:blank' but it seems not to work.
Any other ideas?
webview.src = 'about:blank'
should do what you want.
Related
I have three web view on one screen, and I need the screens to fit the size of each content. How can I solve it?
I already tried using:
let it = productGoal.stringByEvaluatingJavaScript(from: "Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight );")
To get the screen size of the webview content, but it always brings me the current screen size.
This worked for me:
let it = Double(webView.stringByEvaluatingJavaScript(from: "document.documentElement.scrollHeight") ?? "0")
I am using Webview in my UWP app to render some html content. The problem is, when the content is long enough to produce a scrollbar, the scrollbar would hide some of the content behind itself.
How can I fix it?
Try this code ,that's how i fixed it.
this.webView.InvokeScriptAsync("eval", new string[] { SetScrollbarScript });
string SetScrollbarScript = #"
function setScrollbar()
{
//document.body.style.overflow = 'hidden';
document.body.style.msOverflowStyle='scrollbar';
}
setScrollbar();";`
I have inside ScrollView images and i want selected image opened in some new page and have pinch and zoom , i try webview control but i cant load image from my solution path .
void loadhtml()
{
var htmlSource = new HtmlWebViewSource {
Html = "<!DOCTYPE html>\n<html>\n<body>\n<img src=\"myproject.Images.test.jpg\">\n</body>\n</html>"
};
MyWebView.Source = htmlSource;
}
Can i load image from path where is inside my app in WebView ? Another method for pinch and zoom ?
Thanks.
You can in fact load content that is bundled into you app with the Xamarin.Forms WebView. See this link: https://developer.xamarin.com/guides/cross-platform/xamarin-forms/user-interface/webview/
I hope that helps!
I load an local image (tif) on to the UIWebView:
string fileName = "image.tif";
string localDocUrl = Path.Combine (NSBundle.MainBundle.BundlePath, fileName);
webView.LoadRequest(new NSUrlRequest(new NSUrl(localDocUrl, false)));
webView.ScalesPageToFit = true;
The image is bigger than the UIWebView.
Now I want that the image fits in the web view. How can I do this?
i am unable to give comment due to too less comment as i am a new user.
Plz goto nib file and check "Sceling" as "Scale page to fit"
Hope it will work
I'm not sure if this applies directly to a picture, but I had issues trying to get a webview to show correctly on the screen. This is the code that I used and hopefully it can work for you.
var webview = new UIWebView(this.View.Frame);
webview.LoadRequest(new NSUrlRequest(new NSUrl(myCustomUrl)));
this.NavigationController.PushViewController(
new UIViewController() { webview }, true);
Maybe setting the frame will help?
I have read through all of the solutions on here and still am having this issue. I have tried almost anything that I can think of or find.
We just updated to using Xcode 5.0.2 from Xcode 4.6.3 and the code from 4.6.3 worked with no issue. Currently my code looks like this. This is what used to work and I have come back to this because nothing else has worked either.
At this point the size is correct but its in the upper right corner of the screen.
I've also tried adding
actionViewController.View.Center = this.View.Center;
but it didn't change the centre. Any help is greatly appreciated. I'm going crazy at the moment :)
IStoryboard storyBoard = UIStoryboard.FromName ("WorkOrderActions_iPad", null);
VZWOActionViewController actionViewController = (VZWOActionViewController)storyBoard.InstantiateViewController ("VZWOActionViewController");
actionViewController.ModalPresentationStyle = UIModalPresentationStyle.PageSheet;
actionViewController.actionViewControllerID = actionViewControllerName;
this.PresentViewController (actionViewController, true, completionHandler: null);
if (actionViewController.View.Superview != null) {
actionViewController.View.Superview.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
actionViewController.View.Superview.Bounds = new RectangleF (0.0f,0.0f, 924.0f, 648.0f);
}
There is an issue in iOS 7, this can be fix only if you set transition to cross dissolve.
actionViewController.ModalTransitionStyle= UIModalTransitionStyleCrossDisolve