Click here to Skip to main content
16,022,257 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have put the javascript of the CodeProject Newsfeed in an HTA file, which I saved on my desktop. Problem is that when I click a link in the newsfeed, it opens the site in Internet Explorer. Since that program is considered unsafe, I'd prefer using something else (Chrome).

What I have tried:

I looked at the JavaScript code as well as the Newsfeed itself, to see if there is anything in there that chooses the browser. But I couldn't find anything. I guess that HTA files are opened in File Explorer, which maybe linked to IE.
Posted

HTAs are inherently unsafe. They run a stripped-down instance of Internet Explorer - the MSHTML browser engine.

Any links you click on in an HTA will open in Internet Explorer. If you uninstall Internet Explorer, the links will stop working.

It's not clear from your question why you would need to save the newsfeed in an HTA file, but there are almost certainly better options than an obsolete 20+ year-old technology build around a dead browser.
 
Share this answer
 
Comments
Paul K. 2024 25-Jul-24 3:53am    
Thanks. Why? Erm... because I could. But also because I wanted to make a similar newsfeed for my colleagues, but preferably without installing any software. I could've put it on a SharePoint page, but having it on ones desktop makes it more accessible.
So eventually, I asked ChatGTP and it came up with this:

HTML
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="x-ua-compatible" content="IE=edge">
    <title>CodeProject Newsfeed</title>
    <htc:application id="myApp" border="thick" caption="yes" sysmenu="yes" scroll="auto" singleInstance="yes" maximizeButton="yes" minimizeButton="yes"/>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 10px;
            padding: 10px;
        }
    </style>
    <script language="Javascript" type="text/javascript">
        var CP_table_headercolor   = "#ff9900";
        var CP_header_fontface     = "Verdana, sans serif";
        var CP_header_fontcolor    = "white";
        var CP_header_fontsize     = "2";
        var CP_link_fontface       = "Verdana, sans serif";
        var CP_link_fontsize       = "2";
        var CP_link_target         = "_blank";

        function openInDefaultBrowser(url) {
            var shell = new ActiveXObject("WScript.Shell");
            shell.run("cmd /c start " + url);
        }

        // Override existing function to use openInDefaultBrowser
        window.onload = function() {
            var links = document.getElementsByTagName('a');
            for (var i = 0; i < links.length; i++) {
                links[i].onclick = function() {
                    openInDefaultBrowser(this.href);
                    return false;
                };
            }
        };
    </script>
    <script language="Javascript" src="https://www.codeproject.com/webservices/ArticleJS.aspx"></script>
</head>
<body>
    <noscript>
        <a href="https://www.codeproject.com" target="_blank">CodeProject</a> 
        is a place where members can contribute their own ideas, share their own code, and just hang out and help each other learn. 
        Click <a href='https://www.codeproject.com/script/Articles/latest.aspx' target="_blank">here</a> to view the latest updates.
    </noscript>
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900