打开应用程序窗口时无会话共享并避免浏览器中的导航按钮

发布于 2024-12-06 07:18:41 字数 739 浏览 0 评论 0原文

我们使用 VBScript 代码打开应用程序窗口,以避免用户在打开 IE8 窗口时进行前进/后退导航。

这是使用的代码。

Set WshShell = CreateObject("shell.application")
Set IE=CreateObject("InternetExplorer.Application")
IE.menubar = 1
IE.toolbar = 0
IE.statusbar = 0
'here we open the application url
IE.navigate "http://www.google.com" 
IE.visible = 1
WshShell.AppActivate(IE)

这工作正常,但问题是,如果用户打开多个窗口,会话 cookie 将在窗口之间共享。

为此,还有一个解决方案,我们可以在打开 IE 时使用 nomerge 选项

WshShell.ShellExecute "iexplore.exe", " -nomerge http://www.google.com", null, null, 1

。现在我们希望这两个选项都可用。即用户不应该能够向前/向后导航,并且如果打开两个窗口,则不应共享数据。

我们无法让这两件事一起工作。

另外,我们不想要任何全屏模式(即按 F11 后)

任何人都可以提供解决方案吗?

提前致谢。

We are using VBScript code to open the application window to avoid users having forward/back navigation while opening the IE8 window.

This is the code used.

Set WshShell = CreateObject("shell.application")
Set IE=CreateObject("InternetExplorer.Application")
IE.menubar = 1
IE.toolbar = 0
IE.statusbar = 0
'here we open the application url
IE.navigate "http://www.google.com" 
IE.visible = 1
WshShell.AppActivate(IE)

This is working fine, however the problem is that if the user opens multiple windows the session cookies are shared accross the windows.

For this also there is a solution that we can use the nomerge option while opening the IE

WshShell.ShellExecute "iexplore.exe", " -nomerge http://www.google.com", null, null, 1

Now we want both these options to be available. i.e user should not be able to navigate forward/backward and also if two windows are opened data should not be shared.

We were not able to get both these things working together.

Also we do not want any full screen mode(i.e after pressing F11)

Can any one provide the solution?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

热血少△年 2024-12-13 07:18:41

请参阅此密切相关问题的答案:启动 Internet Explorer 7 中的新进程没有工具栏。有几种可行的选择,一种使用 Powershell,另一种使用一些笨拙的 VBScript。

See the answers for this very closely related question: Launch Internet Explorer 7 in a new process without toolbars. There are a couple of workable options, one using Powershell, and one using some cludgy VBScript.

铜锣湾横着走 2024-12-13 07:18:41

据我了解,cookie 是通过实例设置的。多个浏览器窗口仍然是同一个实例。

您也许可以传递程序跟踪的某种 ID 参数,但浏览器不能。这样,无论程序如何运行,它都会有自己的“会话”ID。

我认为你可以使用 javascript 来完成此操作,并使用 asp.net 隐藏字段来读取它。这可能会给您带来您正在寻找的独特性。

<asp:HiddenField ID="HiddenFieldSessionID" runat="server" />

protected void Page_Load(object sender, EventArgs e)
{
    HiddenFieldSessionID.Value = Session.SessionID;
}


<script type="text/javascript">
    function ShowSessionID()
    {
        var Hidden;
        Hidden = document.getElementById("HiddenFieldSessionID");

        document.write(Hidden.value);
    }
</script>

From what I understand, cookies are set by instance. Multiple browser windows are still going to be the same instance.

You might be able to pass in a sort of ID parameter that the program tracks, but the browser doesn't. That way regardless of how the program runs, it will have its own 'session' ID.

I think you can do this with javascript, and reading it using a asp.net hidden field. This might give you the uniqueness you're looking for.

<asp:HiddenField ID="HiddenFieldSessionID" runat="server" />

protected void Page_Load(object sender, EventArgs e)
{
    HiddenFieldSessionID.Value = Session.SessionID;
}


<script type="text/javascript">
    function ShowSessionID()
    {
        var Hidden;
        Hidden = document.getElementById("HiddenFieldSessionID");

        document.write(Hidden.value);
    }
</script>
雨后彩虹 2024-12-13 07:18:41

patmortech 回答的链接中提到的解决方案并不完美,因为 cookie 仍然共享。因此,在 AppToRun 变量中使用 -nomerge 选项,当用户在单台计算机中打开应用程序两次时,该选项会创建两个进程。

在 IE8 中,如果打开两个 Internet Explorer,那么它们将合并为单个进程,因此 -nomerge 选项会在不同进程中打开 IE8 实例。

 On Error Resume Next

AppURL = "http://www.stackoverflow.com"
AppToRun = "iexplore -nomerge"
AboutBlankTitle = "Blank Page"
LoadingMessage = "Loading stackoverflow..."
ErrorMessage = "An error occurred while loading stackoverflow.  Please close the Internet Explorer with Blank Page and try again.  If the problem continues please contact IT."
EmptyTitle = ""

'Launch Internet Explorer in a separate process as a minimized window so we don't see the toolbars disappearing
dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run AppToRun, 6

dim objShell
dim objShellWindows

set objShell = CreateObject("Shell.Application")
set objShellWindows = objShell.Windows

dim ieStarted
ieStarted = false

dim ieError
ieError = false

dim seconds
seconds = 0

while (not ieStarted) and (not ieError) and (seconds < 30)

    if (not objShellWindows is nothing) then
        dim objIE
        dim IE

        'For each IE object
        for each objIE in objShellWindows

            if (not objIE is nothing) then

                if isObject(objIE.Document) then
                    set IE = objIE.Document

                    'For each IE object that isn't an activex control
                    if VarType(IE) = 8 then

                        if IE.title = EmptyTitle then
                            if Err.Number = 0 then
                                IE.Write LoadingMessage

                                objIE.ToolBar = 0
                                objIE.StatusBar = 1
                                objIE.Navigate2 AppURL

                                ieStarted = true
                            else
                                'To see the full error comment out On Error Resume Next on line 1
                                MsgBox ErrorMessage
                                Err.Clear

                                ieError = true

                                Exit For
                            end if
                        end if
                    end if
                end if
            end if

            set IE = nothing
            set objIE = nothing
        Next
    end if

    WScript.sleep 1000
    seconds = seconds + 1
wend

set objShellWindows = nothing
set objShell = nothing

'Activate the IE window and restore it
success = WshShell.AppActivate(AboutBlankTitle)

if success then 
    WshShell.sendkeys "% r"  'restore 
end if

The solution mentioned in the link answered by patmortech is not perfect, as the cookies were still shared. So used the -nomerge option in the AppToRun variable which creates two processes when user opens the application twice in the single machine.

In IE8 if two internet explorers are opened then they are merged into single process so the -nomerge option which opens the IE8 instances in difference processes.

 On Error Resume Next

AppURL = "http://www.stackoverflow.com"
AppToRun = "iexplore -nomerge"
AboutBlankTitle = "Blank Page"
LoadingMessage = "Loading stackoverflow..."
ErrorMessage = "An error occurred while loading stackoverflow.  Please close the Internet Explorer with Blank Page and try again.  If the problem continues please contact IT."
EmptyTitle = ""

'Launch Internet Explorer in a separate process as a minimized window so we don't see the toolbars disappearing
dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run AppToRun, 6

dim objShell
dim objShellWindows

set objShell = CreateObject("Shell.Application")
set objShellWindows = objShell.Windows

dim ieStarted
ieStarted = false

dim ieError
ieError = false

dim seconds
seconds = 0

while (not ieStarted) and (not ieError) and (seconds < 30)

    if (not objShellWindows is nothing) then
        dim objIE
        dim IE

        'For each IE object
        for each objIE in objShellWindows

            if (not objIE is nothing) then

                if isObject(objIE.Document) then
                    set IE = objIE.Document

                    'For each IE object that isn't an activex control
                    if VarType(IE) = 8 then

                        if IE.title = EmptyTitle then
                            if Err.Number = 0 then
                                IE.Write LoadingMessage

                                objIE.ToolBar = 0
                                objIE.StatusBar = 1
                                objIE.Navigate2 AppURL

                                ieStarted = true
                            else
                                'To see the full error comment out On Error Resume Next on line 1
                                MsgBox ErrorMessage
                                Err.Clear

                                ieError = true

                                Exit For
                            end if
                        end if
                    end if
                end if
            end if

            set IE = nothing
            set objIE = nothing
        Next
    end if

    WScript.sleep 1000
    seconds = seconds + 1
wend

set objShellWindows = nothing
set objShell = nothing

'Activate the IE window and restore it
success = WshShell.AppActivate(AboutBlankTitle)

if success then 
    WshShell.sendkeys "% r"  'restore 
end if
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文