alert() statement lets code work, remove it, code dosen't work

Discussion in 'JavaScript' started by man123, Dec 27, 2007.

  1. #1
    Hi
    I have written a code:

    1. function test() {
    2. alert("Press OK to load Teacer !");
    3. document.Tracer.setPoints(window.opener.parent.option.jncurves,window.opener.parent.option.jinfo);

    4. }

    If I remove the line 2 then this code dosen't work. In line 3 I am calling an applet function that is embeded on this page.
    I I keep line 2 then code is working perfectly.

    This is the complete code
    main.asp

    <html>
    <head>
    <script type="text/javascript">

    function test()
    {
    alert("Press OK to load Teacer !");
    document.Tracer.setPoints(window.opener.parent.option.jncurves,window.opener.parent.option.jinfo);
    }

    var parameters;
    parameters = "width=450px,height=250px,left=50px,top=10px,resize=0,scrolling=0";


    function openmypage()
    {

    ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "My_Application_File.asp", "Window Name", parameters)

    }
    </script>
    </head>


    <body>
    <a href="#" onClick="openmypage();test();">Open Ajax Window</a>
    </body>
    </html>



    I am calling My_Application_File.asp file from above code...

    <div style="z-index:0">

    <div id= "mydiv">

    <applet style="z-index:0" id="Tracer" name="Tracer" code="MyApplication.class" codebase="tracer/" width = 400 height =200 VIEWASTEXT>
    </applet>

    </div>


    </div>

    Please help me !!!
    dcm_2001@yahoo.com
     
    man123, Dec 27, 2007 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't see anything wrong at first site.

    Can you put this up somewhere so we don't have to replicate the test case?
     
    MMJ, Dec 28, 2007 IP
  3. Sabbir

    Sabbir Banned

    Messages:
    210
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #3
    I think asp cause some trouble with javascript. you can try vbscript. vbscript goes fine with asp.
    best wishes.
     
    Sabbir, Dec 29, 2007 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    When this happens it's usually somthing to do with timing. An alert pauses script execution untill the visitor deals with the alert.

    Java applets, Flash Movies, & similar things are notorious for not being ready when scripts want to use their methods.

    Try
    setTimeout("document.Tracer.setPoints(window.opener.parent.option.jncurves,window.opener.parent.option.jinfo)", 1000);
    Code (markup):
     
    joebert, Dec 30, 2007 IP
  5. man123

    man123 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks a lot joebert. Problem solved by using code:
    setTimeout("document.Tracer.setPoints(window.opener.parent.option.jncurves,window.opener.parent.option.jinfo)", 1000);
     
    man123, Jan 1, 2008 IP