Problem opening URL

Started by
9 comments, last by rip-off 12 years, 10 months ago
Hi!
I'm trying to open a URL from a Dialog in MFC with the following code.

CWebBrowser2 m_WebBrowserCtrl.Navigate(URL.c_str(), NULL, NULL, NULL, NULL);


But it navigates to the URL at the computers where IE is installed. Otherwise it's not working. I've to read the default browser from Regsitry and open the URL with that browser. How to do this in MFC?
Advertisement
I think CWebBrowser2is using IHTML, which requires IE installed.
[s]If you don't want to depend on IE, try some other library, such like Webkit or Gecko.
[/s](Please ignore it)[s] :rolleyes:
[/s]

https://www.kbasm.com -- My personal website

https://github.com/wqking/eventpp  eventpp -- C++ library for event dispatcher and callback list

https://github.com/cpgf/cpgf  cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.


I think CWebBrowser2is using IHTML, which requires IE installed.
If you don't want to depend on IE, try some other library, such like Webkit or Gecko.

Will the above libraries work with the default browser(not any specific like IE or Chrome) that's installed in a System?
Damn, forgot the very heavy libraries I said.

To open URL in default browser, try Win API ShellExecuteEx
I will do all your need.

Here is some example

https://www.kbasm.com -- My personal website

https://github.com/wqking/eventpp  eventpp -- C++ library for event dispatcher and callback list

https://github.com/cpgf/cpgf  cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.


Damn, forgot the very heavy libraries I said.

To open URL in default browser, try Win API ShellExecuteEx
I will do all your need.

Here is some example


I've already tried this. But I got the following error:

APPLICATION ERROR:

This error has occurred for one of the following reasons:


(i) You have kept the browser window idle for a long time. Your session has expired.
(ii) You have logged in from another browser window.
(iii) You are accessing the application URL from a saved or static page.

If I use,
CWebBrowser2::Navigate()
the same URL opens fine but not opening without IE. What else to do?
Read your post on MSDN, another guy had answered you,

"So, the browser did open, and did navigate to the URL you asked it to navigate to. The server then responded with this page. Figure out why. ShellExecute did its job corretly."

https://www.kbasm.com -- My personal website

https://github.com/wqking/eventpp  eventpp -- C++ library for event dispatcher and callback list

https://github.com/cpgf/cpgf  cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.


Read your post on MSDN, another guy had answered you,

"So, the browser did open, and did navigate to the URL you asked it to navigate to. The server then responded with this page. Figure out why. ShellExecute did its job corretly."


How to find out what's causing this error?
What have you tried?

[quote name='wqking' timestamp='1306477365' post='4816315']
Damn, forgot the very heavy libraries I said.

To open URL in default browser, try Win API ShellExecuteEx
I will do all your need.

Here is some example


I've already tried this. But I got the following error:

APPLICATION ERROR:

This error has occurred for one of the following reasons:


(i) You have kept the browser window idle for a long time. Your session has expired.
(ii) You have logged in from another browser window.
(iii) You are accessing the application URL from a saved or static page.

If I use,
CWebBrowser2::Navigate()
the same URL opens fine but not opening without IE. What else to do?
[/quote]

That error looks an awful lot like something the website is telling you, not your system at any level. I have a sneaking suspicion that whatever website you're trying to direct to has issues with browsers that are not Internet Explorer. Can you access the site fine without code? Simply going to the URL in your browser of choice that is not IE?

[quote name='ratha' timestamp='1306477757' post='4816317']
[quote name='wqking' timestamp='1306477365' post='4816315']
Damn, forgot the very heavy libraries I said.

To open URL in default browser, try Win API ShellExecuteEx
I will do all your need.

Here is some example


I've already tried this. But I got the following error:

APPLICATION ERROR:

This error has occurred for one of the following reasons:


(i) You have kept the browser window idle for a long time. Your session has expired.
(ii) You have logged in from another browser window.
(iii) You are accessing the application URL from a saved or static page.

If I use,
CWebBrowser2::Navigate()
the same URL opens fine but not opening without IE. What else to do?
[/quote]

That error looks an awful lot like something the website is telling you, not your system at any level. I have a sneaking suspicion that whatever website you're trying to direct to has issues with browsers that are not Internet Explorer. Can you access the site fine without code? Simply going to the URL in your browser of choice that is not IE?
[/quote]

No. I can't access even with IE directly. It runs based on a session. How to open a URL that is based on a session with ShellExecute or is there any other way to open a URL that is based on a Session?

This topic is closed to new replies.

Advertisement