Unable to get IPython Notebook's url in WebBrowser - winforms

I am using System.Windows.Forms.WebBrowser to display the webpages in a Windows Forms application. The Url i'm trying to display is the IPython Notebook which is,
http://localhost:8888/tree
and i'm able to achieve this using the below code,
this.webBrowser.Navigate("http://localhost:8888/", false)
Now in this page when I click on the New->Python2 to create a new notebook, it generates a new url which is like,
http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=python2
My requirement is to get this new Url in the WindowsForms application. I've tried the events Navigating, Navigated and I get the new url as,
http://localhost:8888/tree#
And I'm not able to get the right url. Any Suggestions on this? Thanks.

I've managed to overcome this problem by editing the Javascript files in the IPython package. You can find the javascript file at the Ipython installed path,
IPython\html\static\tree\js\newnotebook.js
In newnotebook.js edit this line of code
var w = window.open(undefined, IPython._target);
and add '_self' in order to open the new url in the same window.
var w = window.open('', "_self");
Now I am able to get the url of the page using WebBrowser.Navigated and Navigating methods.

Related

How to open static files from API with React and 'proxy'?

The project I'm working on uses React and proxies a Go server, and images can be displayed with src="/relative/path/to/image", but if I try to open the same route in a new tab it obviously goes through React's routing and doesn't display the image.
What I would like to do is open a new tab with the image from the image route. This is what I most recently tried:
function openImage(image: string) {
const newWindow = window.open("", "_blank", "noreferrer");
if (newWindow) {
const imageElement = document.createElement("img");
imageElement.src = image;
newWindow.document.body.appendChild(imageElement);
}
}
Firstly, newWindow is null when I try to add children to the document. But if I use window.open() without arguments, it is not null, but still doesn't work. The result is a blank opened tab in either case.
How do I specify that the route I want to be opened should be from the server? Or if I can't do that, is there a way to properly add children to the document of the new window?
Thanks for the help.
The issue with opening static resources in a new tab, when you're using React with the proxy property set in development, is that the new window will not use that proxy value the way the React app does. Instead the browser will just add the relative URL on top of the React server's origin address.
jsejcksn was right that this shouldn't be an issue in production, because any proxying in production should work when requests are sent to the site's origin.
Basically the proxying happens at a different stage because the proxy server should cover several services, opposed to the React development server which only covers the React app.
So in order to open those resources from the API in a new window, in development, you can't use a relative path, and must include the server's origin.

URL link preview issue in react JS

We are having one problem while generating a link preview for our react application URL's. Actually we have the requirement to display the dynamic link preview for different URLs.
We are able to add the link preview by using open graph tags in our index.html file placed under the public folder.
But once we tried to add dynamic metadata using the "react-meta" or "helmet" package. it is successfully changing the title of the application. but links preview are not working after making these changes.
so I kindly let me know if there is any way that we can different link preview for different urls for react application. Thanks in advance.

base64 pdf is not showing in IE 11 browser [duplicate]

I receive (from a webservice I don't manage) a string with the content of a pdf file.
On client's side, I use this function:
window.open('data:application/pdf;base64,'+encodeURI(TheStringWithThePdfContent));
As usual, it works in every browser but IE (11 in my case), which shows an alert with the message: "Do you want to allow this website to open an app on your computer?"
If I say no, an empty white page is opened.
If I say yes, it tries to open a "data" file (as it reads from the protocol in window.open, I guess) and, as it doesn't find any application to do that, sends me to the Microsoft application store, which just suggests me to download "iMusic"
Completely useless, of course.
I've changed all the Internet Options I've guessed could help, none works.
Any suggestion?
Thanks in advance,
I found the solution and I want to share anyone who has the same problem. You can see the demo here :
https://jsfiddle.net/quangminh_ln/hy36tnt6/
'use strict';
var data = "...Your PDF base64 string...";
var fileName = "your_file_name";
if (window.navigator && window.navigator.msSaveOrOpenBlob) { // IE workaround
var byteCharacters = atob(data);
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
var blob = new Blob([byteArray], {type: 'application/pdf'});
window.navigator.msSaveOrOpenBlob(blob, fileName);
}
else { // much easier if not IE
window.open("data:application/pdf;base64, " + data, '', "height=600,width=800");
}
The link that I saw for my solution : https://viethoblog.wordpress.com/2016/08/30/loaddisplay-pdf-from-base64-string-bonus-ie-workaround/
Update Reader or Acrobat
Adobe releases free security updates quarterly. Make sure you update your version of Reader or Acrobat to the latest release. The updates often include fixes to common problems. Download the latest free update.
Open Reader or Acrobat.
Choose Help > Check for Updates.
Acrobat 9 and earlier: If a new update is available it installs automatically.
Acrobat X and XI: Click Update and then click Install.
Acrobat DC: Continue to the next step.
Check for updates
When the Updater dialog box appears, click Download.
Update Acrobat
After download is complete, click the Acrobat install icon. In the Acrobat Updater window, click Install.
Update is Ready
After installation is complete, restart your computer and test the PDF again to see if you can view it.
PDF solutions
Refresh or reload the page
Often, just refreshing the page in your browser allows the PDF to load fully.
Hold down the Shift key and press the Refresh or Reload button in the browser.
Try to view a different PDF
Try viewing a different PDF. For example, see if this sample form displays in your browser. If Acrobat or Reader can open the sample form, then the other PDF could be damaged or the web server could be having problems. If possible, contact the individual or company who manages the website.
Try to view a PDF on your hard drive
Determine if your web browser can open a PDF from your local hard drive rather than from the web. For this test, you need a PDF saved on your computer.
In your web browser, do one of the following:
Mac OS: Choose File > Open (or Open File).
Windows: Press Control+O.
Click Browse.
(Windows only) From the Files Of Type menu, choose All Files.
Choose all files
Locate a PDF on your computer, select it, and then click Open.
If the PDF opens, the website you were viewing could have a problem. Contact the individual or company who manages the website.

Changing Silverlight Application name dynamically

I'm creating a deployable module where some parts are written in Silverlight, and I'm making the SL application deployable for OOB usage. However, I want to make Silverlight take the name of the website that it's deployed from, such as, when a user installs it from Example.com, I want to have "example.com application" with the site's own icon in the shortcut. Is there any "supported" method of doing this, or will I be going with locating the XAP file and manually changing AppManifest.xaml inside it?
You will need to find out your URL of your application:
string appURL = Application.Current.Host.Source.AbsoluteUri.Substring(0, Application.Current.Host.Source.AbsoluteUri.IndexOf(#"ClientBin/"));
So this will solve the title problem, next is the icon. You could load the image from the page:
Uri uri = new Uri(String.Format("{0}/favicon.png", appURL));
IconImage.Source = new BitmapImage(uri);
It's not perfect, you will have to manipulate appURL to get the domain name only.

How do I access the existing running windows forms application through url?

I have a windows forms application and which provides a way to search the database based on the provided value. Sometime I need to open the application through a simple html hyperlink with the search result while loading itself. There are two questions/doubts from here.
How to access the existing running windows forms application as url? If this is possible, how can I pass the argument?
If the application is not running, we have to start the application and search the value. This also has to be happened when I click the link.
Simply we can say like, if you open a website link from your outlook email, the link will be opening in existing opened default browser or it will start the new browser(if the browser is not already opened.) I want to achieve the same behavior.
Seems to be the below post is somewhat related to my queries, but this does not solve my problem.
Activate existing browser window with given URL from C# application (without triggering reload)
You can't do this. The default browser launches when you click on a link because it is set up in the registry as the default handler for hyperlinks.

Resources