Visual Cobol Website

[Migrated content. Thread originally posted on 16 September 2011]

Hi,

I've created a website using Visual Cobol and it works very well.

However I need more control over the web browser page itself.

Can any one point me to any code that will show me how to :-

a) "Close" a browser page automatically, after performing some COBOL code.

b) how to disable the browser "back/forward" buttons.

I'm happy to try and convert VB or C# code into COBOL code, just need pointing in the right direction.

Many thanks

Neil.
  • I usually find this type of information by using Google and searching on, for example:
    "asp.net close browser"

    and get pages of results and examples.

    For the two that you mention in this post I found the following that you can do in Javascript:
    (of course if the user has Javascript turned off in his browser then this will not work!)

    Closing the Browser

           method-id Button1_Click protected.
           01 strscript  string value "".
           procedure division using by value lnkSender as object lnkEvent as type System.EventArgs.
           
               If (Not self::ClientScript::IsStartupScriptRegistered("clientScript"))
                  invoke self::ClientScript::RegisterStartupScript(self::Page::GetType(), "clientScript", strscript)
               end-if
                 
           end method.


    Disable Back Button
    There does not seem to be a way to actually disable these buttons.
    This solution simply makes clicking on the back button not do anything.
    You can also programatically handle these events in other ways such as clearing the page cache, etc.

           method-id Button2_Click protected.
           01 strDisAbleBackButton string value "".
           procedure division using by value lnkSender as object lnkEvent as type System.EventArgs.
           
               If (Not self::ClientScript::IsStartupScriptRegistered("clientScript"))
                  invoke self::ClientScript::RegisterStartupScript(self::Page::GetType(), "clientScript",    strDisAbleBackButton)
               end-if
           
           end method.


  • Thanks for the info Chris I will give it a try.
  • Hi Chris,

    Well I have tried both javascript's above and neither do any thing, I have made sure java is enabled but still nothing.

    Do you know of any other method to achieve what I need i.e. disable browser back button, or hide the toolbar.

    Bear in mind there are now many browsers customers use.

    Many thanks for your help in this matter.

    Kind regards

    Neil.
  • Verified Answer

    Neil Willby originally wrote:
    Well I have tried both javascript's above and neither do any thing, I have made sure java is enabled but still nothing.


    Javascript and Java are completely unrelated. You need to check that Javascript is enabled. Also, are you sure you used the scripts correctly? Have you checked them in the page delivered to the browser, using a script debugger?

    Do you know of any other method to achieve what I need i.e. disable browser back button, or hide the toolbar.


    You can't. User agents ("browsers") don't give web applications that degree of control over their behavior. There is nothing you can do, from the web server, to prevent users from navigating away from your page.

    Bear in mind there are now many browsers customers use.


    Yes. There are also many options for restricting what web applications are allowed to do. Customers may have disabled scripting. They may be using an add-on that lets them selectively disable scripting, such as the NoScript add-on for Firefox. They may have a browser which disables certain script features for security reasons. They may be using an add-on like Greasemonkey that lets them inject their own scripts into your pages when they load.

    Also, the Javascript features you're trying may not be standard, or may not be supported correctly by the browser you're testing with.

    Javascript (actually ECMAScript; "Javascript" should be treated as a facility to provide extra functionality for your application. An application that depends on it simply will not work for some users.
  • ok thanks for info.

    so looking at page :-

    1) msdn.microsoft.com/.../ms536651.aspx

    i currently call my WebPage2 from WebPage1 using the following cobol code:-

    2) invoke self::response::redirect("WebPage2.aspx")

    is it possible to introduce some of the features from point 1 into my "invoke" statement in point 2?
  • So you are looking to incorporate DHTML into your ASP.NET pages is that correct?

    Any code to be added as DHTML or Javascript would have to be placed in the web page itself, possibly in the Page_Load event.

    You couldn't add this type of functionality to the invoke self::response::redirect("WebPage2.aspx") as all this does is tell the browser to display the new web page.

    What exactly is the task that you are trying to accomplish here?

  • Hi Chris,

    I just trying to have more control of the internet browser features, such "back" button, hide the toolbar etc etc.

    I tried the javascript in the cobol program to disable the back button and it didnt work, so I'm just looking at other options that will hopefully take care of all the different types of browsers.

    Surely the browsers have functions that are common and can be controlled programmatically from with in the Cobol code.

    Kind regards

    Neil.
  • I think that the main problem here is that you are trying to control a web application as if it were a standard Windows application which it is not.

    The user is supposed to have complete control over the functionality and appearance of the browser itself and they certainly don't want to run a web application that starts closing their browser and disabling their toolbar buttons, etc. for them as they should be free to run your application or go to another web page at their own choosing.

    You should try to control the flow of your web application from within the code running in the web pages themselves and not by trying to change the behavior of the browser.

    You can add javascript and DHTML elements to your web pages but this should be to add more functionality to your application without interfering with the operation of the browser itself.

    Perhaps others could chime in here as I am certainly not an expert on web application design and it would be great to hear how others have tackled this issue...

    Thanks.