Script errors in C# webbrowser control - javascript

I am developing a Twitch chat bot and I want to be able to display the current chat in the bot using a webbrowser control. I get "An error has occured in the script on this page. URL : https://web-cdn.ttvnw.net/sw.js"
I can get it to work with gecko or cefsharp web browsers, however; they are way too big. I want to keep my application under 10mb.
Is there anyway around this?

The Script file(s) (.js) on your website should be at bottom of the html file and then after (If you have access to it)
Add meta query to support in IE
The query is
I hope this will help!

I recently moved over to using WebView2 to solve this issue.
https://learn.microsoft.com/en-us/microsoft-edge/webview2/
It uses the Edge browser as base and it works perfectly. The browser-code is very similar to the old WebBrowser as well.

Related

How can I detect if the webpage is being rendered in WebBrowser Control?

Most of the people who will access my app will do so from a preinstalled software on their pc that has a browser component built with Microsoft's WebBrowser Control which is just Internet Explorer wrapper.
I want to know if there's a way I can detect, using Javascript, or any other method from inside my website, when it is being rended using this wrapper.
The reason I want to do this is that software was already built and goes to the home page of my site. But I want to redirect them directly to the login screen if they are accessing from that wrapper.
By default the WebBrowser Control uses IE7 so you can check the user agent string (I doubt your other users will be using such an old Internet Explorer version as their browser causing a faulty recognition).
However, this is not a perfect solution, if you can modify the preinstalled software and deliver a new version to people that will be using it you can send a specific header along with the request to determine its origin.
I don't think you can do this accurately. As Samuil stated, you can hack it a bit and maybe catch some of it.
Why not set the default page of your website to be the login page so the user goes to that page regardless?

Weinre how to add new targets?

Hello I am new to Weinre and I need to debug my website which seems to act strange when opened using an IOS platform.
So I am using Weinre to debug it. I installed the tool and tested it running with the demo targets in the server itself.
Now I need to add my website as a target and run it with an iphon (or ipad) and debug it with Weinre. I don't know how to add my website as a target, I cannot manually add the
<script src="http://123.456.7.89:8080/target/target-script-min.js#anonymous"></script>
script (do not have permission to manually change the page). so How can I do my debugging with Weinre?
Thanks
You can try using a bookmarklet. The main weinre server page actually has a bookmarklet in it, for itself, that you should be able to use directly, if you can figure out how to set up a bookmarklet for your device. This seems to change release-release for mobile browsers, so you might want to do a google search on "bookmarklet" and your device's name or the OS release, to see if anyone has any tips.

Sencha Touch 2: Facebook JS SDK not working on device, only in computer-browser

I'm developing a Sencha Touch 2 app that uses the Facebook JavaScript SDK to show a Facebook feed in a list. In my browser (localhost) it works perfect, but when I launch my app on my device (iPhone of iPad), the feed does not load. Neither when I open it via localhost in Safari on the devices.
When I use the Safari-console on my iPhone, it shows two logs which don't appear on my computer:
"JavaScript logfile at line 44: http://connect.facebook.net/en_US/all.js: Received message of type object from https://s-static.ak.facebook.com, expected a string"
Is this causing the problem? Maybe the FB-functions of the Javascript SDK don't get recognized on my device?
Can anybody help me with this? Thanks!
Where are you defining the script of fb and where is the div fb-root the defined I had the same problem before but it was because the div was always override or overwrited by another view, so check that if you can post some of the code would be better,
Do you have the fb domains added to the app url whitelist? I have had similar problem and it was solved by adding the fb domains to the access origin tag of the config file.

Enable script run in web browser using java script codes

I designed a web page which contains some javascripts, but when I'm running the page in certain browsers like internet explorer my scripts get blocke and the browsers asks for manual enabling of the script in that browser
I need java script or jquery code for enabling script run in any browser automatically. Can anyone help me please?
Thank you
It is impossible for a website to turn on JavaScript if it is disabled in the browser.
Design your site with progressive enhancement and unobtrusive JavaScript in mind.
If, by "certain browsers like internet explorer", you mean "Internet Explorer will not run my code" (as opposed to "Browsers wil JS turned off will not run my code") then you may just need to learn how to write cross-browser compatible code.
Without a specific example of code that does not work (along with the specific error messages you receive), that topic is too broad to cover on StackOverflow.
Sounds like you are running the website locally, ie opening the file not serving it from a web server. Try running a local web server or hosting your site on a free online service and as long as the browser doesn't have JavaScript disabled the messages shouldn't show up.

Reading / Writing files in Javascript - IE6

I need a database storage system for Javascript where the state can be maintained on the local disk.
Here comes the spanners in the works :-
It only needs to support Internet Explorer but the minimum version must be IE6
Files need to be written so they can be read in again later (upon closing and re-opening of browser)
There can be no web server (unless it's extremely easy to distribute and does not require a install) since the HTML pages will be distributed on USB.
Does anyone know of any solutions that might help here?
Have fun playing with userData. Apparently it does what you want in IE6/7
Then localStorage for IE8/9
Or you can use the heavier store.js which does the feature detection for you and apparently works in IE6+.
It should work in IE9 but no garantuees. I would recommend store.js as it's easier for maintenance and just works out of the box. You can also support other browsers that way.
I don't know if it's supported in IE6, but JScript appears to have some level of support for this through FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:\\testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();
According to Write binary data with FileSystemObject write(), ADODB.Stream appears to be an alternative.
For strictly local IE work use HTA Applications. Then you can access local resources (text files, ADO databases) without security problems.
try to read this post: Read/write to file using jQuery
Hope this helps.
I would suggest that you not try to read/write using JavaScript but instead head down the road of embedding a small web server on the USB drive. I did this for an app once and it worked out well. I used the Cassini web server.
I created two projects in visual studio. First, I created an ASP.Net web site to read/write from an SQLite database. This site displayed all my content and was built just like any other ASP.Net site. Second, I created a Windows Forms application that hosted the Cassini web server and presented the user with a form that contained a single web browser control. This made the user experience very simple ... they just clicked MYAPP.EXE from the root of the USB drive and the form opens, starts the web server, and navigates the browser control to the start page of the web site.

Categories