Python WebBrowser Open In Same Tab - python-webbrowser

running this line:
webbrowser.open(page.path, new=0, autoraise=True)
I always get the page opened in a new Tab.
How can I get it in the same Tab as it should be using new=0?

This can't be done unfortunately.
You can set the variable to whatever you want but browser tab behaviour is hard-set in modern browsers and will override it. You'll find that you won't be able to use new=1 to open in a brand new window either, for the same reason. It will always just be a new tab.
The last update to the webbrowser module in the Github was about the same age as this question, I wonder if this has been abandoned.

Related

How do I get my button to redirect to a web page within the app?

So far, I have it so that when a user presses a button, a browser opens and redirects the user to my desired url. However, I want this to happen within the app instead of a web tab. How can I do this?
Use the BrowserComponent, just add it to the center of a border layout form and set the URL for that component. Check out the list of main components in Codename One within the developer guide.
Define a xml layout containing a widget called webview. Then in your activity you implement a listener to your button which invokes that xml with the desired page to load inside your webview. Google to find some code and return here with your code problems, if you find some. If this will be the case, open new questions provinding detailed info about your matters then we can help more. Best.
EDIT: Excuse me, just now, re-reading your question I think I really understand it, and the solution is very simple, just a line of code (to instruct your app to open a webpage inside your webview, and not the regular browser, outside your app). Try this:
wv = (WebView) findViewById(R.id.myWebView);
wv.setWebViewClient(new WebViewClient()); // needed to open url inside our webview, otherwise it will open at the default browser
wv.loadUrl(url);

Access Specific PDF Page in WPF WebBrowser Control

I have a webbrowser control in my application that is used to display pdf files that have been created in iTextSharp and are stored locally on the hard drive.
I would like to be able to navigate the file (next, previous, first, last, toc) from my application rather than using the inbuilt nav of the reader in the browser.
I have seen that you can navigate to specific pages by using
Browser.Navigate("filename.pdf#page=?);
This works the first time but when trying to navigate to a different page, it makes the browser disappear completely with no errors. However, I can reload the file without problem if I don't have the #page=? suffix on the file url though. Any ideas on this?
Alternatively, is there anyway in iTextSharp of adding something to the file to allow for it to be navigated from an external command?
All the official parameters that can be used to navigate through a PDF using parameters in the query string after the ? character are listed in a document published by Adobe: Parameters for Opening PDF Files
You already mentioned the page parameter. Another option could be using named destinations: nameddest=destination. In this case, you need to add the anchor with name destination to the file using iTextSharp.
Note that not all viewers implement these parameters. Adobe supports them in Adobe Reader and in the Adobe Reader plug-in, but there is no guarantee that they will work in pdf.js (Firefox), Pdfium (Google Chrome),... If your browser disappears when using an open parameter, you may have hit a bug in the browser or the viewer plug-in that causes the browser to crash. iTextSharp nor iText can crash a browser ;-)
There are no other ways you can navigate a PDF from an external application. The only thing you can do, is to add JavaScript to the PDF so that it always opens at the same page. This is done using an open action. I don't think this solves your problem as it would mean that you have to change the PDF file every time you want it to open at a different page.

WP7 WebBrowserTask without url entry textbox

This might not be possible but I thought I'd check with everyone.
Is it possible to load a WebBrowserTask on WP7 but to have the url entry box collapsed? I'd also like to set IsHitVisble to false?
The reason I want to do this is to load a url (through databinding) but ensure that the user can't browse to other links on the page. I also need to keep the phones share control in the tool bar so I can't just use a webbrowser control and set the source to the url.
Does anyone have any ideas?
Not possible. You can use a WebBrowserControl inside your own app, but it's not recommended.
Basically such odd/weird limitations as this, don't belong in any modern day craftsmanship. And thus why it isn't a possibility (thanks Microsoft!)

How can I make a url embedded in the about dialog box appear as a hyperlink? (resource script .rc)

I have an application written in c that has no dialog box.
However, when you right click the icon you get a floating menu and from there you can choose the about option. This will open an about dialog box. I have inside a link to some webpage, that can be pressed- that will open a browser and navigate to the URL. However, I am unable to make that URL appear as a hyperlink (all that GUI related work is done via the resource .rc file only).
Does anyone know how to color that link in blue and underline to make it appear as a hyperlink through resource script only?
Thank you
I haven't tried this myself but it looks like you can use the CONTROL statement in the resource script to include the SysLink class (which requires common controls v6/Win XP, and will therefore mean you also need a manifest in your application). For more details see http://msdn.microsoft.com/en-us/library/bb760706%28VS.85%29.aspx.
However, you will need to handle the notification from the SysLink control in order to launch the browser and you would need to call InitCommonControlsEx() before the dialog resource is used. That might stop all your GUI work being done by the rc file.
Another alternative would be to register a new window class, subclass from the SysLink control and customise the window message that would normally send the click notification to the parent in order to launch the browser. You could then use your custom class name in a CONTROL statement in the rc file. You still have more work to do but all the GUI handling would be done for you.

Out of browser option is not loaded with controls

I changed the silverlight project property file in to out of browser option. The screen is loaded with no controls. Any idea?
Yes. It is working fine the browser and when it is set to out of browser application, the application is installed in the start up as well as desktop. when we load it is opened with a blank screen and no control was loaded.
It could be related to unhandled exception happened inside App.xaml.cs during start-up. For instance, if you try to reach any in-browser-application only objects such as System.Windows.Browser.HtmlPage, you will get Null reference exception. You should be able to find this out by put a break point inside App.xaml.cs.
Here is an example that you can see in browser application but you will get a blank window in out of browser.
System.Windows.Browser.HtmlPage.Document.DocumentUri;
To support both in-browser and out-browser, you should do the following.
if (Application.Current.IsRunningOutOfBrowser)
{
// MessageBox.Show("Application.Current.Host.Source = " + Application.Current.Host.Source.ToString());
return Application.Current.Host.Source;
}
// MessageBox.Show("DocumentUri = " + System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString());
return System.Windows.Browser.HtmlPage.Document.DocumentUri;
If this is not the case, please try to rebuild your solution by toggling "Enable the application out of the browser". Sometimes you have to build twice (the first one without the check, the second one with the check) before you can see the out-of-browser application window.

Resources