Way to launch a browser w/ specific webpage without using ShellExecute? (Visual C++) - visual-c++

I want to add a button to my visual C++ form that will open with a specific browser. So far for links I've been using:
System::Diagnostics::Process::Start("UrlHere")
Which, as standard, opens with whatever your default browser is.
I'm wondering what the process would be to force the URL to open with a specific browser and if it's possible without the use of ShellExecute?
Edit - You are correct, this is C++/CLI. Removed the C++ Tag.
Edit Edit - Apologies if it came across as misleading. Some slight elaboration;
The buttons will launch to application URL's, some of which can only be used in Internet Explorer, others that CAN (and should) be used in Chrome. This is why I need to avoid using the default browser and have different buttons using different browsers when launching URLs

Before answering the 'how', I'd like to ask the question "should you be implementing this?"
By not launching the user's default browser, you are subverting the user's decision.
Perhaps the user prefers a particular interface, and is willing to live with the incorrect renderings that come with it.
Perhaps the user has a browser addon that they really need, such as a screen reader for the blind.
You are requiring additional software installed that the user may or may not want.
Perhaps the user doesn't want Chrome. Perhaps the user prefers FireFox.
You are saying that you know which browser is best, now and forever.
What if the next version of IE makes it work with the sites that are currently Chrome-only? What if the next version of Chrome fixes the sites that are currently IE-only?
What if the site changes so that it works in more browsers?
Do you go back and release a new version of your software that changes the browser for particular sites?
You're trying to solve a problem that may already be fixed.
Both Chrome and Firefox support a addon that will render a tab using the IE engine. It can be set to automatically activate when certain URLs are seen.
Perhaps there is a browser that already works with all your sites, that you don't know about.
Therefore, my recommendation is no, do not do this. The user has decided which browser they want to use, respect that decision and use the default browser.
That said, here's how you would do it: You could use the CreateProcess method, but you're in managed-land, so you might as well use it. Use the Process class to launch the new process for you.
Process^ browserProcess = gcnew Process();
browserProcess->StartInfo->UseShellExecute = false;
browserProcess->StartInfo->FileName = "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe";
browserProcess->StartInfo->Arguments = "http://www.google.com";
browserProcess->Start();

Related

Chrome extension to change Desktop wallpaper

I'm diving into the world of Chrome Extension development, primarily because there is a very small feature that is missing in Chrome that I miss dearly. The context-menu option to "Set as background/wallpaper" like that found in Firefox. Sounds trivial, but it's convenient.
I have most of the "basic" stuff worked out with the manifest file, am able to install it, even managed to get it to show up as a context menu item.
The problem obviously is that I am wanting to mess with a user's OS-level settings which is extremely difficult because of security issues (fully understand this).
I found an extension that allowed this in older versions of Chrome, and it looked like the developer used some type of .dll and C++ to accomplish this.
I'm not really sure how to make this work.
Since that Chrome doesn't allow these kind of manipulations (such as your PC's settings), you will need to create a native application that will run beside your extension. When the user chooses the image from your extension and selects "use as wallpaper", you will use the native messaging API to send a message to your desktop application, that will set the wallpaper (and do whatever else you can't do within a chrome extension) for you.
You can use the chrome.wallpaper app api to set the wallpaper after using the messaging api to send the image from your extension.

Why do user agents / browsers lie

I have read several articles on feature detection and that it is more reliable than browser detection because browsers lie.
I couldn't find any information on why they lie. Does anyone know the reason why they would do that?
As far as I understand it, Webmasters do browser sniffing to find the capabilities of a browser and limit what they send to the browser. If a browser lies about it's capabilities they will receive more from the webmaster, you can read more:
http://farukat.es/journal/2011/02/499-lest-we-forget-or-how-i-learned-whats-so-bad-about-browser-sniffing
http://webaim.org/blog/user-agent-string-history/
The reason is simple:
Because web sites look at the user agent string and make assumptions about the browser, which are then invalid when the browser is updated to a new version.
This has been going on almost since the begining of the web. Browser vendors don't want their new versions to break the web, so they tweak the UA string to fool the code on existing sites.
Ultimately, if everyone used the UA string responsibly and updated their sites whenever new browser versions come out, then browsers wouldn't need to lie. But you have to admit, that's asking quite a lot.
Feature detection works better because when a new browser version comes out with that feature, the detection will pick it up automatically without the either browser needing to do anything special nor the site owner.
Of course, there are times when feature detection doesn't work perfectly -- eg maybe if a feature exists but has bugs in a particular browser. In that case, yes, you may want to do browser detection as a fall-back. But in most cases, feature detection is a much better option.
Another more modern reason is to just avoid demands to install mobile apps (where product owners contol what I can and can't do with content. No thanks!).
Today Reddit started to block viewing subreddits in case they detect a mobile browser in UserAgent so I had to change it just to be able to view content.

Embedded Signing with Safari on Mac not working as intended

I successfully (with much frustration) got our c# embedded signing to work on our site, however, that was before I tested with Safari on a Mac. Safari does not allow Third party sites to open in an iframe without already having a cookie for that site stored. If you either open the site beforehand or allowing all cookies, the document will show embedded. However, even messing around with that, the redirection after completion is not working. The please wait popup does not redirect back to my site. I am looking for any embedded solution that supports mac.
The process works great on windows, but does not work on Safari for Mac and is intermittent with Firefox and Chrome on mac.
I am looking for any non-iFrame embedded solutions that I could implement that should work on all platforms and browsers.
Since you have embedding working in terms of generating a URL token, it's up to you how to access that URL. We've seen developers write their own programs to view where they have complete control over the iFrame and can do whatever they like with it, and another solution we've seen is to use a web browser control.
see this SO link
The only workaround that I know of is to pop up a new browser window. I know there is work being done to make it work without cookies, but at this time the new browser window is your only choice.
Sorry about that.

Automatically disable JavaScript on Web Browser

I need a way to "disable JavaScript" / "not run JavaScript" in the web browser.
Is it possible to do it using JavaScript or some other automatic way?
Update: reason for this? Easy, there are some "online TV sites" where they use several iframes pointing to "cross site urls" and it is annoying to get several "advertising" pop ups all the time. By coding my own webbrowser "add-on/extension" I've tried to "delete" html nodes and some Javascript and it works for the "main page" code, not for iframe "Cross Domain URL".... so I think disabling javascript AFTER the movie starts, would be a nice solution.
Update 2:
The video I want is a result of a iframe cascade chain.... I've tried all the way to "catch" the final "url" result using fiddler and other tools, but its getting hard since this different "cross domain" communication is sharing "runtime keys" to avoid what I want to accomplish (perhaps with more time I can do it) but this is why I thought that an easy and fast solution would be just disable javascript after the movie starts.
NOTE: other extensions such as Adblock and similars DO NOT work, since the website detect it and the video never loads.
No, it is not possible to programmatically disable the JavaScript on a user's browser using another JavaScript add-on/extension.
However, it may be possible if you use PHP as a proxy to intercept the pages you want, and strip out all script tags. You might even be able to extract the video URL you want and play it using another (flash?) player.
If you are a system administrator and want to disable JavaScript on all your network's computers, please post on SuperUser instead.
You can't disable, but you can overwrite the javascript functions.
alert = function(){}
alert("hello")
You can even kill those iframes by tag name.

Always using google chrome frame meta tag for standard compliant page, is good idea?

I was thinking to add meta tag always in all the websites.
That will trigger google chorme frame to load for users who already installed. I can see the benefits but is there any concerns or facts that I should know before I do that?
Testing in google chrome is enough or testing in google chrome frame explicitly required?
Thanks
Note: please do not mention current know problems "print" and "download" issue. I'm sure those will get fixed soon :)
The only argument against chrome frame that I have seen so far is Microsoft's - "Google Chrome Frame running as a plugin has doubled the attach area for malware and malicious scripts."
Also, you may run into problems with frames. If you have chrome frame on your page and someone has that page iframed on their site you may run into some problems. More info:
http://groups.google.com/group/google-chrome-frame/browse_thread/thread/d5ffe442658bc60e/e6d7a4c1c179c931?lnk=gst&q=iframe
You should only need to test in Chrome Frame for (X)HTML, CSS, and JavaScript...basic stuff. If you are using AJAX (while trying not to break the back button), worried about caching, cookies (accessed via javascript), or other potentially browser-specific browser interactions I suggest testing on the IE+CF platform...at least until the CF team announces 100% interoperability between CF and IE.
Check out the CF Google group for more issues.
Are there any concerns or facts you should know? Yes: Not everyone has Google Chrome Frame installed.
You are adding a new user agent that you will need to test and debug against, without removing the need to test and debug the user experience for other browsers (notably plain IE by itself).
If you don't make the IE user experience equivalent to the Google Chrome experience, then you are alienating a significant percentage of users. Depending on your website and its expected users, the impact of this may range from undesirable to unacceptable. If you do make the user experience equivalent, then there is no point in adding the meta tag.

Resources