Working around IE7s prompt bug

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nanakse85
    New Member
    • Dec 2007
    • 7

    Working around IE7s prompt bug

    Hi all!

    I'm very appreciative that someone have come out with such a method to go around IE7's prompt bug as shown in the below link, but I don't really know how to use it.



    This is what I did and the bottom one is my original section of my javascript code, but I think I use it wrongly.


    [code=javascript]<script type='text/javascript' src='IEprompt.j s'></script>
    <script type='text/javascript'>

    function promptCallback( "") {

    alert("Enter the number of Lucky Dip Chances you want to buy.");

    location='<?=te p_href_link(FIL ENAME_LUCKY_DIP , '', 'SSL')?>';

    } else {
    location="lucky dip.php?osCsid= <?=$_GET['osCsid']?>&action=purch ase&qty=" + number;
    }

    IEprompt("How many Lucky Dip Chances you want to buy?.", "");
    </script>
    [/code]



    Original::

    [code=javascript]<script>

    function main() {

    var input = prompt("How many Lucky Dip Chances you want to buy?.", "");

    var number = input;

    if(number == "") {

    alert("Enter the number of Lucky Dip Chances you want to buy.");

    location='<?=te p_href_link(FIL ENAME_LUCKY_DIP , '', 'SSL')?>';

    } else {
    location="lucky dip.php?osCsid= <?=$_GET['osCsid']?>&action=purch ase&qty=" + number;
    }

    }

    </script>

    [/code]

    I just started learning javascript, so I'm sorry that I don't understand the terminology. Sorry about that. This is previously how I link to the front page, upon using yout script, can we retain the link: <a href="javascrip t:main()"> ?

    Thank you so much!

    Warmest Regards,
    Gordon
    Last edited by acoder; Dec 12 '07, 11:52 AM. Reason: fixed code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!

    Try:
    [code=javascript]function promptCallback( number) {
    if (number == "") {
    alert("Enter the number of Lucky Dip Chances you want to buy.");

    location='<?=te p_href_link(FIL ENAME_LUCKY_DIP , '', 'SSL')?>';

    } else {
    location="lucky dip.php?osCsid= <?=$_GET['osCsid']?>&action=purch ase&qty=" + number;
    }
    }
    IEprompt("How many Lucky Dip Chances you want to buy?.", "");
    [/code]

    Comment

    • nanakse85
      New Member
      • Dec 2007
      • 7

      #3
      Hi there, Thank you so much for your help, but the page just refresh and there were no effects.

      I've changed it to :

      [CODE=javascript]<script type='text/javascript' src='IEprompt.j s'></script>
      <script type='text/javascript'>

      function promptCallback( number) {

      if(number == "") {

      alert("Enter the number of Lucky Dip Chances you want to buy.");

      location='<?=te p_href_link(FIL ENAME_LUCKY_DIP , '', 'SSL')?>';

      }

      else {
      location="lucky dip.php?osCsid= <?=$_GET['osCsid']?>&action=purch ase&qty=" + number;
      }

      IEprompt("How many Lucky Dip Chances you want to buy?.", "");

      }

      </script>
      [/CODE]
      This time round i can see the IE7 prompt to go around the problem of IE7's prompt bug for javascript. However, it just blink once and I was not able to type in any values.

      Is it because the way I link which may create problems too like what i did below?

      [HTML]<td width="50%" align="center"> <b><a href="javascrip t:promptCallbac k()">Click here to buy 1 Lucky Dip Chance for <?=getCostPerLu ckyDip()?> PV</a><br>Note: Lucky dip chances are not refundable for PVs.</b></td>
      [/HTML]
      Thank you so much for your help, sorry for my "newbie" skills.
      Last edited by acoder; Dec 13 '07, 09:04 AM. Reason: Added code tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by nanakse85
        Is it because the way I link which may create problems too like what i did below?

        [HTML]<td width="50%" align="center"> <b><a href="javascrip t:promptCallbac k()">Click here to buy 1 Lucky Dip Chance for <?=getCostPerLu ckyDip()?> PV</a><br>Note: Lucky dip chances are not refundable for PVs.</b></td>
        [/HTML]
        You need to call IEPrompt, not promptCallback.

        Comment

        • nanakse85
          New Member
          • Dec 2007
          • 7

          #5
          Yup it works, but however the first prompt was undefined, the sentence I type in IE prompt came out in a blink after i enter any value.

          Thanks once again!

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            What does your full code look like now?

            Comment

            • nanakse85
              New Member
              • Dec 2007
              • 7

              #7
              Originally posted by acoder
              What does your full code look like now?
              i separate into 2 parts as in between there are other codings:

              [CODE=javascript] <script type='text/javascript' src='IEprompt.j s'></script>
              <script type='text/javascript'>

              function promptCallback( number) {

              if(number == "") {

              alert("Enter the number of Lucky Dip Chances you want to buy.");

              location='<?=te p_href_link(FIL ENAME_LUCKY_DIP , '', 'SSL')?>';

              }

              else {

              location="lucky dip.php?osCsid= <?=$_GET['osCsid']?>&action=purch ase&qty=" + number;

              }

              IEprompt("How many Lucky Dip Chances you want to buy?.", "");

              }

              </script>
              [/CODE]

              The second part where the javascript is called in is:

              [HTML]<form action="luckydi p.php?action=bi d&osCsid=<?=$_G ET['osCsid']?>" method="post">
              <table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#1484d 2">
              <tr>
              <td>
              <table border="0" width="100%" cellspacing="1" cellpadding="3" class="luckyDip Contents">
              <tr>
              <td width="50%" align="center"> <b>Your Lucky Dip Chances:</b> <?=getNumChance s($_SESSION['customer_email _address'])?></td>
              <td width="50%" align="center"> <b><a href="javascrip t:main()">Click here to buy 1 Lucky Dip Chance for <?=getCostPerLu ckyDip()?> PV</a><br>Note: Lucky dip chances are not refundable for PVs.</b></td>
              </tr>[/HTML]

              Hope this will be clearer in assessing the error.
              Last edited by acoder; Dec 20 '07, 02:36 PM. Reason: Added code tags

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Change main() to:
                [CODE=javascript]function main() {
                IEprompt("How many Lucky Dip Chances you want to buy?.", "");
                } [/CODE]promptCallback should get called automatically.

                Comment

                • nanakse85
                  New Member
                  • Dec 2007
                  • 7

                  #9
                  Originally posted by acoder
                  Change main() to:
                  [CODE=javascript]function main() {
                  IEprompt("How many Lucky Dip Chances you want to buy?.", "");
                  } [/CODE]promptCallback should get called automatically.

                  Thank you so much man!!! It works perfectly. hehe. I'm trying on other stuff, i'll ask around for help if needed. This community rocks!!!

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    You're welcome. Glad it helped.

                    Comment

                    Working...