Page 2 of 2 FirstFirst 12
Results 14 to 21 of 21

Thread: Keith Collins: Running program on internet

  1. #14
    kc
    Guest

    kc: Changed "JScript" to "javascript" and...

    ...it works in IE.

    kc

  2. #15
    Magician
    Guest

    Magician: OK, now...

    Unfortunately it doesn't work with Firefox "out of the box". But I did some debugging and with 3 changes you should be able to get it to work in most browsers.

    1. <script for="window" event="onload" language="javascript"> ... </script>

    In Firefox, this script is executed before the controls on the page exist, which causes problems. Besides, according to the standard, script does not have attributes called "for" or "event". The simplest fix is to take out this script block, then find your <body> tag and change it to:

    <body onload="RecomputeHand();">

    2. frmStrat

    You'll need to replace frmStrat with document.frmStrat in all your Javascript (i.e. everywhere except in the form tag itself).

    3. txtDecks_onkeypress

    This looks like one of those areas where broswer behaviour isn't fully standardised. I found an explanation and a workaround here. In the input tag for txtDecks, add "event" as a parameter to txtDecks_onkeypress like this:

    onkeypress="return txtDecks_onkeypress(event)"

    Then replace your txtDecks_onkeypress function with:

    function txtDecks_onkeypress(e) {
    var key = window.event ? e.keyCode : e.which;
    if (! (key >= 48 && key <= 57))
    e.returnValue = false;
    }


    Hope this helps.

  3. #16
    kc
    Guest

    kc: Re: OK, now...

    > Unfortunately it doesn't work with Firefox "out
    > of the box". But I did some debugging and with 3
    > changes you should be able to get it to work in most
    > browsers.

    > 1. In Firefox, this script is executed
    > before the controls on the page exist, which causes
    > problems. Besides, according to the standard, script
    > does not have attributes called "for" or
    > "event". The simplest fix is to take out
    > this script block, then find your tag
    > and change it to:

    > > onload="RecomputeHand();"> 2. frmStrat
    > You'll need to replace frmStrat with
    > document.frmStrat in all your Javascript (i.e.
    > everywhere except in the form tag itself).

    > 3. txtDecks_onkeypress This looks like one of those
    > areas where broswer behaviour isn't fully
    > standardised. I found an explanation and a workaround
    > here . In the input tag for txtDecks, add
    > "event" as a parameter to
    > txtDecks_onkeypress like this:

    > onkeypress="return
    > txtDecks_onkeypress(event)" Then replace your
    > txtDecks_onkeypress function with:

    > function txtDecks_onkeypress(e) {
    > var key = window.event ?
    > e.keyCode : e.which;
    > if (! (key >= 48 && key
    >
    > e.returnValue
    > = false;
    > } Hope this helps.

    It definitely helps . Thanks for taking the time.

    kc

  4. #17
    kc
    Guest

    kc: Re: OK, now...

     
    > Unfortunately it doesn't work with Firefox "out
    > of the box". But I did some debugging and with 3
    > changes you should be able to get it to work in most
    > browsers.

    > 1. In Firefox, this script is executed
    > before the controls on the page exist, which causes
    > problems. Besides, according to the standard, script
    > does not have attributes called "for" or
    > "event". The simplest fix is to take out
    > this script block, then find your tag
    > and change it to:

    >
    > onload="RecomputeHand();"

    I changed from event="onload" to event="onload()" (void parameter list.)
    This still works in IE. I think (could be wrong) that defining window onload
    like I did is supposed to override window onload in the body element. I found that
    some make use of this to open popup windows with window.open("http...,height,
    width,scrollbars,resizable,etc."). I mostly don't like those, but I suppose
    they could be used in good taste. Maybe that's why this
    doesn't work in Firefox. If the change I made doesn't work I'll try
    defining onload in the body element.

    >2. frmStrat
    > You'll need to replace frmStrat with
    > document.frmStrat in all your Javascript (i.e.
    > everywhere except in the form tag itself).

    I qualified frmStrat with document.frmStrat as you suggested.

    > 3. txtDecks_onkeypress This looks like one of those
    > areas where broswer behaviour isn't fully
    > standardised. I found an explanation and a workaround
    > here . In the input tag for txtDecks, add
    > "event" as a parameter to
    > txtDecks_onkeypress like this:

    > onkeypress="return
    > txtDecks_onkeypress(event)" Then replace your
    > txtDecks_onkeypress function with:

    > function txtDecks_onkeypress(e) {
    > var key = window.event ?
    > e.keyCode : e.which;
    > if (! (key >= 48 && key <= 57)
    > e.returnValue = false;

    I basically did as you suggested:

    function txtDecks_onkeypress(event) {
    if (! (event.keyCode >= 48 && event.keyCode <= 57))
    event.returnValue = false;
    }

    It works in IE. I'm not sure if I'll need to qualify event as window.event
    for other browsers, but it seems to maybe make sense that I shouldn't since I'm
    not passing window.event to the function.


    > } Hope this helps.

    Once again, it does .

    kc

  5. #18
    Magician
    Guest

    Magician: Re: OK, now...

    > I qualified frmStrat with document.frmStrat as you
    > suggested.

    That one change made about 90% of your code work. I can actually get strategies now.

    > I changed from event="onload" to
    > event="onload()" (void parameter list.)
    > This still works in IE. I think (could be wrong) that
    > defining window onload
    > like I did is supposed to override window onload in
    > the body element. I found that
    > some make use of this to open popup windows with
    > window.open("http...,height,
    > width,scrollbars,resizable,etc."). I mostly don't
    > like those, but I suppose
    > they could be used in good taste. Maybe that's why
    > this
    > doesn't work in Firefox. If the change I made doesn't
    > work I'll try
    > defining onload in the body element.

    Sorry, that didn't help. When I load the page I get an error in the JavaScript Console that says:

    document.frmStrat has no properties

    I think this is because when Firefox runs this code it hasn't loaded the rest of the page yet, whereas IE loads the whole page before running it. (Again, probably something that isn't covered in the spec.) You could try moving this script to the bottom of your page but I've tried using the body tag's onload attribute and it seems to work.

    > I basically did as you suggested:
    > function txtDecks_onkeypress(event) {
    > if (! (event.keyCode >= 48 && event.keyCode
    > event.returnValue = false;
    > }
    > It works in IE. I'm not sure if I'll need to qualify
    > event as window.event
    > for other browsers, but it seems to maybe make sense
    > that I shouldn't since I'm
    > not passing window.event to the function.

    The difficulty here is that Firefox and Netscape don't use event.keyCode, they use event.which whereas IE uses event.keyCode but not event.which. (Opera tries to please everybody and uses both.) I discovered this from the page I linked to last time (Tutorials - KeyPress validation).

    That page also presents a solution which is to get the value of the key pressed with this expression:

    var key = window.event ? e.keyCode : e.which;

    This uses e.keyCode if window.event is defined and e.which if it isn't. From the table on the page you can see that those browsers that set window.event also set e.keyCode, whereas those that don't set e.which. This is what I'd call a "clever hack".

    > Once again, it does .

    No problem. We might be getting a bit off-topic here, even for the Computing for Counters forum. Feel free to email me if you wish.

  6. #19
    kc
    Guest

    kc: Try now - hopefully OK *NM*


  7. #20
    Magician
    Guest

    Magician: Last thing (I hope)

    The window.onload function is working now but in txtDecks_onkeypress, event.returnValue = false; needs to be replaced with return false;.

  8. #21
    kc
    Guest

    kc: Done - OK in IE - thanks :) *NM*


Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

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

About Blackjack: The Forum

BJTF is an advantage player site based on the principles of comity. That is, civil and considerate behavior for the mutual benefit of all involved. The goal of advantage play is the legal extraction of funds from gaming establishments by gaining a mathematic advantage and developing the skills required to use that advantage. To maximize our success, it is important to understand that we are all on the same side. Personal conflicts simply get in the way of our goals.