【问题标题】:Opening Browser Instances from different Vendors打开来自不同供应商的浏览器实例
【发布时间】:2015-08-25 21:33:29
【问题描述】:

我知道这个主题有点奇怪,但我给出了它,因为我的客户端需要从 Chrome 浏览器打开 IE 实例。

我知道这个问题已经被问过很多次了,但由于这是我的客户要求,我不能忽视。他们已经在最新的浏览器上升级了应用程序,但其中一项功能仍然仅受 IE 浏览器支持。 我知道我可以做的一种方法是创建一个 HTA 文件并打开默认浏览器,但是将 HTA 集成到 javascript 中仍然是一个很大的痛苦(如果有任何想法,请告诉我)。在 Chrome 浏览器中为 WScript.Shell 创建 ActiveXObject 也很痛苦。

请指导我如何才能打动我的客户,因为这完全是关于我的小企业。

谢谢

【问题讨论】:

  • 您的意思是要在 HTA 中使用 Chrome 浏览器打开链接吗?您可以编辑和发布到目前为止您在 HTA 中尝试过的代码吗?
  • 什么功能只有IE才支持?我在 IE 团队工作,我们一直在左右剥离专有的东西——对于您的客户来说,找到一种基于标准的方法会更好,而不是想出一些在浏览器之间跳来跳去的方法。他们期望在未安装 IE 的机器上发生什么?
  • @JonathanSampson.. 他们支持 IE,所以他们已经在他们的机器上安装了 IE。他们将他们的应用程序升级到 chrome,并且在一个页面中,有一个链接,他们想在该链接上打开 IE 浏览器。
  • @s_k_t 我明白了,但是他们依赖 Internet Explorer 中的什么 [功能]?因为它很有可能已从更高版本中删除,并且几乎可以肯定它已从 Microsoft Edge 中删除。

标签: google-chrome internet-explorer browser cross-browser hta


【解决方案1】:

这是一个 HTA 示例,向您展示如何使用 IE、Chrome、Firefox 和默认浏览器打开链接以及如何传递一些命令行。

<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="Open links with IE, Chrome and Firefox and how to pass command line"
BORDER="THIN"
BORDERSTYLE="NORMAL"
ICON="Explorer.exe"
INNERBORDER="NO"
MAXIMIZEBUTTON="NO"
MINIMIZEBUTTON="NO"
SCROLL="NO"
SELECTION="NO"
SINGLEINSTANCE="YES"/>
<title>Open links with IE, Chrome and Firefox and how to pass command line</title>
<SCRIPT LANGUAGE="VBScript">
'************************************************************************************
Option Explicit
 Function Executer(StrCmd,Console)
    Dim ws,MyCmd,Resultat
    Set ws = CreateObject("wscript.Shell")
'La valeur 0 pour cacher la console MS-DOS
    If Console = 0 Then
        MyCmd = "CMD /C " & StrCmd & " "
        Resultat = ws.run(MyCmd,Console,True)
        If Resultat = 0 Then
            'MsgBox "Success"
        Else
            MsgBox "Une erreur inconnue est survenue !",16,"Une erreur inconnue est survenue !"
        End If
    End If
'La valeur 1 pour montrer la console MS-DOS
    If Console = 1 Then
        MyCmd = "CMD /K " & StrCmd & " "
        Resultat = ws.run(MyCmd,Console,False)
        If Resultat = 0 Then
            'MsgBox "Success"
        Else
            MsgBox "Une erreur inconnue est survenue !",16,"Une erreur inconnue est survenue !"
        End If
    End If
    Executer = Resultat
End Function
'************************************************************************************
Sub window_onload()
    CenterWindow 480,400
End Sub
'************************************************************************************
Sub CenterWindow(x,y)
    Dim iLeft,itop
    window.resizeTo x,y
    iLeft = window.screen.availWidth/2 - x/2
    itop = window.screen.availHeight/2 - y/2
    window.moveTo ileft,itop
End Sub
'************************************************************************************
Sub Ip_Publique()
    Dim Titre,URL,ie,objFSO,Data,OutPut,objRegex,Match,Matches,ip_public
    Titre = "Adresse Ip Publique !"
    URL = "http://monip.org"
    If OnLine("smtp.gmail.com") = True Then
        Set ie = CreateObject("InternetExplorer.Application")
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        ie.Navigate (URL)
        ie.Visible=False
        DO WHILE ie.busy
            Sleep 100
        Loop
        Data = ie.document.documentElement.innertext
        Set objRegex = new RegExp
        objRegex.Pattern = "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
        objRegex.Global = False
        objRegex.IgnoreCase = True
        Set Matches = objRegex.Execute(Data)
        For Each Match in Matches
            MsgBox "Votre IP Publique est : "& Match.Value,64,Titre
        Next
        ie.Quit
        Set ie = Nothing
    Else
        MsgBox "Vérifier votre connexion internet puis re-executer ce script",48,Titre
        Exit Sub
    End If
End Sub

'**************************************************************************************
Sub Sleep(MSecs)'Fonction pour faire une pause car wscript.sleep ne marche pas dans un HTA
    Dim fso,objOutputFile
    Set fso = CreateObject("Scripting.FileSystemObject")
    Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
    Dim tempName : tempName = "Sleeper.vbs"
    If Fso.FileExists(tempFolder&"\"&tempName)=False Then
        Set objOutputFile = fso.CreateTextFile(tempFolder&"\"&tempName, True)
        objOutputFile.Write "wscript.sleep WScript.Arguments(0)"
        objOutputFile.Close
    End If
    CreateObject("WScript.Shell").Run tempFolder&"\"&tempName &" "& MSecs,1,True
End Sub
'**************************************************************************************
Sub SSID_names()
Dim objShell,fso,File,strContents,objRegEx,objMatch,colMatches
    set objShell = CreateObject("WScript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Executer("netsh wlan show all > Wlan.txt",0) = 0 Then
        Set File = fso.OpenTextFile("Wlan.txt",1)
        strContents = File.ReadAll
        Set objRegEx = New RegExp
        objRegEx.IgnoreCase = True
        objRegEx.Global = True
        objRegEx.Multiline = True
        objRegEx.Pattern = """([^""]+)"""
        set colMatches = objRegEx.Execute(strContents)
        For each objMatch in colMatches
            MsgBox "SSID name: " & objMatch.Value,64,"SSID name"
        Next
    End If
End sub
'***************************************************************************************
Function OnLine(strHost)
Dim objPing,z,objRetStatus,PingStatus
    Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & strHost & "'")
    z = 0
    Do    
        z = z + 1
        For Each objRetStatus In objPing
            If IsNull(objRetStatus.StatusCode) Or objRetStatus.StatusCode <> 0 Then
                PingStatus = False
            Else
                PingStatus = True
            End If      
    Next    
        sleep 200
        If z = 4 Then Exit Do
    Loop until PingStatus = True
    If PingStatus = True Then 
        OnLine = True
    Else
        OnLine = False
    End If
End Function
'***************************************************************************************
Sub WLAN_Networks()
    If Executer("netsh wlan show profiles > Wlan_tmp.txt & netsh wlan show networks >> Wlan_tmp.txt & netsh wlan show interfaces >> Wlan_tmp.txt & cmd /U /C Type Wlan_tmp.txt > Wlan_Networks.txt",0) = 0 Then
        Call Executer("Start Wlan_Networks.txt & Del Wlan_tmp.txt",0)
    End If
End Sub
</script>
</head>
<p>Links List (examples) :</p>
<ol>
<li><a href="#" onClick="Call Executer('Start iexplore.exe www.google.com',0)">Lien Google avec iexplore.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe http://bbat.forumeiro.com/',0)">Lien BBAT avec Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start Firefox.exe www.developpez.net',0)">Lien developpez.net avec Firefox.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.yahoo.fr',0)">Lien Yahoo avec Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.autoitscript.fr',0)">Lien Autoitscript.fr (Français) avec Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.autoitscript.com',0)">Lien autoitscript.com (Anglais) avec Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start www.sfr.fr',0)">Lien SFR avec votre navigateur by default</a></li>
</ol>
<BODY text=white bgcolor="DarkOrange" TOPMARGIN="1" LEFTMARGIN="1">
 <center><button onclick="Call Executer('mode con cols=90 lines=15 & Color 0A & Title Ping sur www.stackoverflow.com by Hackoo & Ping www.stackoverflow.com',1)">Ping on www.stackoverflow.com</button><hr>
 <center><button onclick="Call Executer('FindStr /? > HelpFindStrTmp.txt & cmd /U /C Type HelpFindStrTmp.txt > HelpFindStr.txt & start HelpFindStr.txt',0)">Help sur FindStr</button>
 <button onclick="Call Executer('ipconfig /all > configTmp.txt & cmd /U /C Type configTmp.txt > MyIPconfig.txt & Del configTmp.txt & start MyIPconfig.txt',0)">IpConfig</button>
 <button onclick="Call Executer('mode con cols=80 lines=50 & Color 9B & Title Hackoo & netstat -a',1)">Netstat</button>
 <button onclick="Call Executer('mode con cols=60 lines=10 & Color 0A & Title Hackoo & arp -a',1)">Arp</button><hr>
 <button onclick="Call Executer('mode con cols=80 lines=30 & Color 9B & Title Tracert vers www.stackoverflow.com by Hackoo & Tracert www.stackoverflow.com',1)">Tracert to  stackoverflow</button><br><hr>
 <center><button onclick="Call Ip_Publique">IP Publique</button>
 <button onclick="Call SSID_names()">SSID WLAN</button>
  <button onclick="Call WLAN_Networks()">WLAN Network</button>
 </center>
 </center>
</body>
</html>

【讨论】:

    猜你喜欢
    • 2017-06-25
    • 1970-01-01
    • 2017-06-25
    • 1970-01-01
    • 2012-09-29
    • 1970-01-01
    • 2018-12-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多