How to programmatically change browser URL - c++

In my C++ Windows application I use ShellExecute to open a remote PDF file in the internet browser at a certain PDF Destination (dynamic bookmarks provided by Adobe Acrobat Reader):
ShellExecute(NULL, "open", "https://www.myweb.cloud/guide.pdf#dest_1", NULL , NULL, SW_SHOWNORMAL);
Then if I want to move to another Destination, another call to ShellExecute (with #dest_2 in the URL) simply open another page in the browser and download the PDF again opening it at that Destination.
Is there a way to programmatically change the URL (from #dest_1 to #dest_2) without making the browser to open a new page e re-dowload the PDF?
I also use LibCurl in my application in order to retrieve data from remote servers. Can I reach my goal with LibCurl? If so, could you plese show me a code sample?
Thanks in advance.

External links opened with ShellExecute are always opened in a new tab by default. Chrome can't change this behavior. Early Firefox had an option for opening an external link in a currently active tab, but does not seem to have it now.
You can download files with libcurl, see url2file example. After a file has been downloaded, you can open it in a certain application with ShellExecute. You just need to find an application, that is suitable to your requirements. For example Adobe Reader does not seem to support opening in the same tab 1, 2. As #KJ commented while I was typing my answer, sumatrapdf -reuse-instance seem to be suitable for you.
You can use Edge WebView2 component in your app instead of a browser.

Related

Blank applet layout coming in Siebel before OpenUI rendering happens

We are using Siebel citizen portal application (IP 15.12). After login, we reach in to a landing page with 3 applets. These applets have some custom fields etc, but there is no UI customization we did (ie no PM/PR etc).
Now when we login, a blank layout of the applet appears for a few seconds (especially first load or after clearing cache) and then renders the original applet with Open UI layout. Since this is a customer facing application, our client has a lot of concern on appearing the blank layout before the actual rendered applet.
Could anyone throw some light here? Is this an Open UI behavior, if so is there any workaround for this?
With IP 15.18, We had similar issue of the list applets not loading data on initial (home page load) after login. Only the list applet titles were displayed but the form applet loaded elements, showing the busy cursor forever...
We were getting "Error downloading file define:siebel/htmltmplmgr" error in the browser console. we debugged and found that the localeobject.js was not loading, which is the dependency file mentioned in htmltmplmgr.js...So we added preload define parameter in the htmltmplmgr.js in the beginning to load the localeobject.js file before even the main function starts...then it started working...try this...
On first load or after clear cahce, it needs to load all JS files (vanilla) and other required files in Open UI. So, this is the default behavior of OpenUI.
Nothing much we can do with this. Else you can tweak down all unnecessary files from downloading.
I found this blog very useful, you can check.
http://www.askmesiebel.com/category/siebel-8-1-1-10-upgrade-issue/
edit the file htmltmplmgr.js in below folders
$SIEBEL_ROOT/siebsrvr/webmaster/siebel_build/scripts/siebel/
$SIEBEL_ROOT/SWEApp/public/enu/23048/scripts/siebel/
go to define section and add dependency files inside the square brackets
define("siebel/htmltmplmgr",[]
define("siebel/htmltmplmgr",["siebel/siebelconstants.js","siebel/localeobject.js"]
Note that you have to edit the files in both folders you can create a backup before making changes. If you just replace in public folder when you restart siebel server files will be overwritten from webmaster/siebel_build folder to public folder . Hence you have to replace in both folders and restart siebel server and web server.

How to open a wsdl file in the browser

When I double click on the wsdl file it shows a download window to download that wsdl file, I want to open that file in the browser (I select Internet Explorer to open this kind of file and after that this problem starts),
Can I do something so that when I double click on the wsdl it opens in the browser?
Browser is not the right tool for this. Open the file with Notepad++ or VS Code or simlar. To change file associations in windows, open the file by right clicking and using openwith.
i have wsdl file but on double click it is not opening in the browser
Okay here we go:
The problem is, when you open it in Internet Explorer (IE) the IE reads the header of the file which would be something like Content-type: file because windows handles it as file instead of Content-type: text/xml. If it would come from a (proper installed) webservice (even if it's localhost) you would get the right Content-type and it would open in browser as XML. Have a look at this SQ question (How to open wsdl in browser). That's a "problem" of the IE.
So I think you can't open it in IE on the way you want to easily. You can try to change your security settings (Tools -> Internet options -> Security) and disable "Downloading" - maybe then it will be opened in IE directly. Can't test that on my PC due restrictions but I'm not even sure this will work. And even if yes you'll block all other downloads too!
Alternatives to have a look at your WSDL:
Open the file with an texteditor, like notepad
Open the file with another browser, at least Firefox and Chrome show it as XML (didn't try any other browsers)

How to get the source of the page loaded in IWebBrowser2?

From a BHO (Browser Helper Object) in Internet Explorer, how do I get the full source code of the page currently loaded in the web browser when I have its IWebBrowser2 interface?
Do I have to download it again from the url where it resides or is there a way to get the copy that internet explorer downloaded and used to render the page?
I tried getting the outerHTML of the html element of the current document, but it returns the source code already preprocessed. I need to get it in the same form you see it when you clock "View Source Code" in the Internet Explorer.
Thank you for any helpful information!!!
You can query the browser's Document property for IPersistStream or IPersistFile and then call its Save() method. But when querying the browser for its HTML, you are likely to get the processed HTML, which may include DOM changes from scripts.
To get the original HTML, you should download it yourself directly from the source URL, or at least extract the file from the browser's local cache.

IIS6: setting up gzip compression for cfm/js/css files

I'm new to IIS. In short, I'm facing issues to set up the gzip http compression for "cfm js css" file types in IIS6.
The reference resource I followed is at:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/502ef631-3695-4616-b268-cbe7cf1351ce.mspx?mfr=true
Here are the exact steps I did:
In IIS Manager, double-click the local computer, right-click the Web Sites folder, and then click Properties.
Click the Service tab, and in the HTTP compression section, select the Compress application files check box to enable compression for dynamic files.
Select the Compress static files check box to enable compression for static files.
Change the 'Temporary directory:' to 'C:\Inetpub\compressed_static_files'.
Under Maximum temporary directory size, click 'Unlimited' radio button.
Click 'Apply' button and then click 'OK'.
However, these settings are for .htm, .html, .txt and .asp, .exe and .dll file type only. So, in order to add .js, .css and .cfm, I ran the following commands according to the instruction at the url: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5bce429d-c4a7-4f9e-a619-5972497b932a.mspx?mfr=true
Exact steps are:
cd c:\Inetpub\AdminScripts
cscript adsutil.vbs SET W3SVC/Filters/Compression/Deflate/HcFileExtensions "htm html txt js css"
cscript adsutil.vbs SET W3SVC/Filters/Compression/gzip/HcFileExtensions "htm html txt js css"
cscript adsutil.vbs SET W3SVC/Filters/Compression/Deflate/HcScriptFileExtensions "asp dll exe cfm"
cscript adsutil.vbs SET W3SVC/Filters/Compression/gzip/HcScriptFileExtensions "asp dll exe cfm"
To activate this, I restarted IIS. Steps I followed are:
In IIS Manager, right-click my local computer and select 'All Tasks > Restart IIS...'.
Select 'Restart Internet Services on ' and click OK.
Click 'End now'.
At this point, the server is restarted and now I tested whether the http compression is working or not with the following steps:
Open my web site in FireFox and go to any page with .cfm extension.
Open up FireBug.
Check 'GET' Request Headers for .cfm file. I saw 'Accept-Encoding: gzip, deflate'. This is what the browser sends to the server.
Now, check 'GET' Response Headers for .cfm file. There is even no 'Content-Encoding:' header. I am supposed to see 'Content-Encoding: gzip' here to confirm the server sent .cfm file as gzip encoding.
The same case for 'js css' and even 'html' file too. I think it must be some very basic thing I'm missing here. It will be great if anyone could give me a hint on this.
Thanks in advance.
Gen
Not much help to the OP, over 2 years after the question was asked, but for the benefit of anyone else finding this in Google (as I did), the problem here is with the syntax.
cscript adsutil.vbs SET W3SVC/Filters/Compression/Deflate/HcFileExtensions "htm html txt js css"
should be
cscript adsutil.vbs SET W3SVC/Filters/Compression/Deflate/HcFileExtensions "htm" "html" "txt" "js" "css"
Note the quotes are around each item in the list, not the whole list
On IIS6 I always do it by editing the meta-base directly.
You'll have to check the setting on the web-server properties to be able to do this and be sure to make a backup of the meta-base first e.g. check it in to your source repository
Jeff Atwood covers it here: http://www.codinghorror.com/blog/2004/08/http-compression-and-iis-6-0.html

How does IE downloading is achieved?

I often click on a file link in the IE and a download box just pops out. But what happens behind this scene? I know that IE always talks to web server with HTTP protocol, and HTTP is text based.
So is IE download achieved with HTTP protocol? If so, how could arbitrary file format be downloaded over a text based protocol?
And I am currently trying to make a web app which will direct my customer to download some file. My current design is to implement a web service. Customer will call this web service and the web service will return the file download URL. But then I don't know what to do with the URL. Could I just use something like File.Copy to copy the file from the URL to local disk? Or how should I treat the URL? If there's a better design, please teach me.
Many thanks...
By specifying the right content type, you can tell the browser what kind of data it is you are sending.
In addition, there are special encodings (like Base 64) that allow binary content to be displayed as text, using only a limited set of characters and escaping everything else.
Then, there is nothing you need to do with the url. IE will know whether it can or cannot open the file and will show the download box accordingly.
maybe it's like
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>