Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2003
    Location
    At work...still
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer A few more functions...

    Another set of functions I have used to make my life easier.

    By chance someone else will find use for them.

    Once again I write for IE (4 to 6) as that is what I have to use.

    PHP Code:

    // used to cancel unwanted events, my most common use is
    // <FORM onSubmit=fEventCancel() > as most time I don't let
    // submits happen outside of code/script...WRG
    function fEventCancel() {
       
    event.returnValue=false;
    }
    // used to disable the backspace at the document level, like this:
    // document.onkeydown = fKillBackspace;
    function fKillBackspace() {
       
    // Use onKeyDown="fOnKeyDo(8,'window.event.cancelBubble = true;')" 
       // on input fields that you wish the backspace key to work on...WRG
       
    if (window.event && window.event.keyCode == 8) { // try to cancel the backspace
          
    window.event.cancelBubble true;
          
    window.event.returnValue false;
          return 
    false;
       }
    }
    function 
    fSetAsNextTab(element) {
       
    // Use as the onBlur action...WRG
       
    element.focus();
    }

    function 
    fPopCenterWindow(strURLstrWindowNameintWinHintWinWboolIEModalD){
       
    // Basic Centered Popup window...WRG
       
    var intLeftPos = (screen.width) ? (screen.width-intWinW)/0
       
    var intTopPos = (screen.height) ? (screen.height-intWinH)/0
       
    if ((boolIEModalD) && (window.showModalDialog)) {
          var 
    newWindow window.showModalDialog(strURLwindow'dialogHeight:'+intWinH+'px;dialogWidth:'+intWinW+'px;center:yes;help:no;resizable:no;status:no');
       } else {
          var 
    newWindow window.open(strURLstrWindowName'height='+intWinH+',width='+intWinW+',top='+intTopPos+',left='+intLeftPos+',toolbar=no,minimize=no,status=no,memubar=no,location=no,scrollbars=yes')
       }
    }
    function 
    fOnKeyDo(intKey,strDo){
       
    // Do action when key is pressed...WRG
       
    var keyCode event.keyCode
       
    if (keyCode == intKey) {
          eval(
    strDo);
       }
    }
    // Used in a frame to return a form object from that frameset's opener document object
    function fOpenerWindowForm(boolIEModalD,strForm){
       if ((
    boolIEModalD) && (window.showModalDialog)) {
          if ((
    parent.window.dialogArguments) && (eval("parent.window.dialogArguments."+strForm))) {
             return 
    parent.window.dialogArguments;
          }else{
             return 
    parent.opener// replace with top.opener if needed
          
    }
       }else{
          return 
    parent.opener// replace with top.opener if needed
       
    }
    }
    // Used in a frame to return that frameset's opener document object
    function fOpenerWindow(boolIEModalD){
       if ((
    boolIEModalD) && (window.showModalDialog)) {
          if (
    parent.window.dialogArguments) {
             return 
    parent.window.dialogArguments;
          }else{
             return 
    parent.opener;// replace with top.opener if needed
          
    }
       }else{
          return 
    parent.opener;// replace with top.opener if needed
       
    }
    }
    // Hide an object
    function fHideObj(Obj) {
       if (
    Obj.style.display != "none") {
          
    Obj.style.display "none";
       }
    }
    // Unhide an object
    function fUnHideObj(Obj) {
       if (
    Obj.style.display != "") {
          
    Obj.style.display "";
       }

    Last edited by WillGibson; 12-17-2003 at 09:00 PM.
    Why?
    Ok, but Why?

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You might want to put comments inside each one describing its purpose, what inputs it requires and what its output will be as well as what browsers it works in.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New Coder
    Join Date
    Dec 2003
    Location
    At work...still
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That would help

    Added some comments.

    Will
    Why?
    Ok, but Why?

  • #4
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks

    thanks

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry man, but most of my comments are critisism:

    Disabling the backspace key is not something I would condone. Manipulating keyboard returns as part of form validation is, imo, a highly dubious practise which creates confusion for users. And doing it in order to "control" history navigation is even worse - you simply shouldn't be trying to do that, and it only affects unaware IE-users anyway, compounding the perception of that browser as a security monster with no respect for user's preferences.

    btw - does cancelBubble really have that effect in IE? That doesn't make any sense, because keyboard events don't bubble.

    I also disagree with the use of modal dialogues, whether on the web or in local applications. I consider them the last resort of bad interface design, forcing the user into a fixed order of input purely for the convenience of the author.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #6
    New Coder
    Join Date
    Dec 2003
    Location
    At work...still
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    All my sites are Intraweb, I'm not using that as an excuse. What that does mean is, I know my users. To be honest, most of them are brick dumb. Any complication that I can avoid by limiting the actions and activities of my users I will do. They thank me and the support desk thanks me.

    If I had suave users I could do things different. It would be less work for me and in general make my life easier. I would welcome it. The process of educating users is sloooow, at least with mine. I have not the time, energy or money to deal with it in a proper fashion.

    By giving my users less freedom, I give them less ways to hurt themselves. Why? Because that means I and my developers spend less time cleaning up the mess of a "user error" and more time doing productive work. (I know user errors should not cause huge problems in well designed systems, but I did not design the old systems I have to interface with)

    And yes onKeyDown, onKeyUp and onKeyPress do bubble in IE6.

    btw criticism is the only way any of us get better. We must question ourselves and others. Please keep it up.

    Thanks,
    Will
    Why?
    Ok, but Why?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •