开发者

No session share and avoid navigation buttons in browser while opening application window

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 b开发者_如何学Coth 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.


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.


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>


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜