How to Redirect Gecko Javascript Console messages to a file? - geckofx

Is there any way to redirect the javascript console to a file?
I found this link
https://bitbucket.org/geckofx/geckofx-29.0/issues/9/how-to-get-javascript-consolelog-error
but it requires using devtools that im not going to have in the field.
There must be a simple way to redirect to a C# method.
Any help is appreciated.

Capture the ConsoleMessage event and save each row to a file:
geckoWebBrowser.ConsoleMessage += GeckoWebBrowserOnConsoleMessage;
void GeckoWebBrowserOnConsoleMessage(object sender, ConsoleMessageEventArgs e)
{
AppendToFile(e.Message);
}

Related

How to handle navigation erros with "xamarin + Xam.Plugin.Webview" cross-platform

I am using xamarin + Xam.Plugin.Webview to build a cross-platform application "https://github.com/SKLn-Rad/Xam.Plugin.Webview"
Everything is fine, but I want to handle the navigation errors:
1- why I get errors for linked css and js file in the web page?
2- How to read only errors which come from the page itself like, 404 and others.
3- I want to hide the webview from the form and show friendly page if I cannot load the content of the page.
4- Is there a way to keep navigation events rais only for the source link, not for the linked css or js files?
Finally, I tried to tack all the errors, e.g. "FormswebView_OnNavigationError". but sometimes I get 404 error, while the page is correctly working fine because this 404 error was just for a linked file "css, js, images" in the pages only which not prevent the page from working. I want to handle, "no connection", "cannot load", "server busy", and all kind of errors that will prevent the user to see the content. All solutions should be work in cross-platform, please.
In brief, how to know if the page finally displayed or not?
Update
Sorry, I am not a native english speaker.
I want just to know if my webpage is loaded or not.
I do not want the use to see any error pages.
I cannot count on "OnNavigationError" Event it is not usefull. It raised for some css, js errors, even if page is correctly loaded.
some times it raised 404 "not found" error for linked css, js files, and the webpage is loaded
I want to override all webview error pages.
I hope if I make it more clear
Regards
Thanks in advance
UPDATE
Sorry, it is too long to add a comment
As you see, these are all the Webview events:
private void FormswebView_OnNavigationStarted(object sender, Xam.Plugin.WebView.Abstractions.Delegates.DecisionHandlerDelegate e)
{
}
private void FormswebView_OnNavigationError(object sender, int e)
{
//Sometimes I get e = 404, but this is just for a linked icon or css file
//while the page is already existed and displayed
//sometimes I get e = 404 for the page itself and "error page" displays instead of my page
//How to know when to catch errors and override it?
//How to overrid all the built-in error pages?
}
private void FormswebView_OnNavigationCompleted(object sender, string e)
{
}
private void FormswebView_OnContentLoaded(object sender, EventArgs e)
{
// Now how to know if the page is loaded or not?
}

Catch windows.external.notify posted message from UIWebview in UIViewController Xamarin-iOS

I have a scenario where I'm trying to login from UIWebview and if authenticated successfully then I'm getting a string token using script snippet window.external.notify I'm able to get token in windows phone using myWebView.ScriptNotify+=WinNotify; and in android using myWebView.AddJavascriptInterface(new ExternalInterface(),"");
but the problem is that I'm not able to detect any code snippet in iOS webview to read this notify script.
I've tried This where I've used IWKScriptMessageHandler but didn't work.
Can you guys please help me to get it done in iOS?
I've done something like this a some while ago for Azure Access Control Services. The code can be found here: https://github.com/Cheesebaron/Cheesebaron.MvxPlugins/blob/0e8b7765fe375d1d4998552074d664e6cf5397a3/AzureAccessControl/AzureAccessControl.Touch/Views/AccessControlWebAuthController.cs
Basically what this does is injecting a Notify script into the page, when that script is invoked, it navigates to a specific URL that I know and from that I can grab the payload.
private const string ScriptNotify = #"
<script type=""text/javascript"">
window.external = {
'Notify': function(s) {
document.location = 'acs://settoken?token=' + s;
},
'notify': function(s) {
document.location = 'acs://settoken?token=' + s;
}
};
</script>";
So the code above navigates to acs://settoken?token= when the notify script is invoked. You can detect this in UIWebView.ShouldStartLoad by checking the url scheme. If it matches the one in the notify script you are done.
To inject the script, I implement NSUrlConnectionDelegate and in the FinishedLoading override I inject it as part of the data and make the UIWebView load that content instead.

How to redirect a page to new window using codeigniter redirect function

i need make redirecting my content in new tab after some code checking.
if ($this->form_validation->run('name') == FALSE) {
//...
Show form errors in some windows
//..
} else {
redirect("home/bill_print");
Please help.
You can't use a server-side language (PHP) to control client-side behavior. You can Open a URL in a new tab using JavaScript window.open function.

Does websocket not work with IWebBrowser2::Navigate?

I am writing small html websocket application. This html page works fine at IE window but if same page is tried to open using IWebBrowser2::Navigate then it throws an error "WebSocket is undefined" in standard java script error message box.
Following is sample javascript code:
function myFunction()
{
ws = new WebSocket("ws://" + "127.0.0.1"+ "8070" +"/" + "NSCOMString");
}
Could you please let me whether websocket is implemented inside the navigate method?
Regards,
Anand Choubey
The IWebBrowser2 control by default runs in compatibility mode, see this article on the IEBlog for details on how to circumvent this behavior.

Ajax file Upload Control (Asp.net 4.0)

I am developing a website in asp.net. On a page i have placed 5 Ajax File Upload control.
But i am unable to get the "filename" of the uploaded file in each control.
Please help me
Thanks In Advance......
You can get the file name in the UploadComplete event fired when the file upload is completed.
Example:
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string filePath = MapPath("~/upload/") + Path.GetFileName(e.FileName);
AjaxFileUpload1.SaveAs(filePath);
}
Reference here: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AjaxFileUpload/AjaxFileUpload.aspx

Resources