Problem with javascript call in compiled version

charco

New member
I have a call to a javascript function which works fine in the uncompiled version, but is throwing an error in the compiled version.

The javascript function opens a new document and populates it with HTML including some variables passed from an earlier part of the .js file.

ERROR MESSAGE:

“Access violation at address 03D31905 in module HEIERun.dll. Read of address 00000000.”

The program then usually crashes saying that there is a running script when navigating to another page.

What does this mean and how can I solve it?

In prior versions of HTMLexe there was no problem with this, but now it has appeared.
 
Precisely that.

The .js call runs a function that opens a new document using window.document.open(), which presents users with a certificate of achievement.

Here is an example:

function openWin(){
if(numq<10){
numq='Too few questions’
time='Let’s be serious here’
coeff='errr you haven’t got one’
percentage=‘Don’t bother me now’
stars=(‘Try setting more than 9 questions next time!’);
}
else{
var gs=’'
var time=(setting-secs)
var coeff=200totalcorrect/(setting-secs)
coeff=coeff/Math.sqrt(numq)
coeff=Math.round(coeff)
Code:
    if(percentage>85 && coeff>=50){
        var grade=7}
    else if (percentage>85 && coeff<50){
        var grade=6}
    else if (85>percentage && percentage>=70 && coeff>=30){
        var grade=6}
    else if (85>percentage && percentage>=70 && coeff<30){
        var grade=5}
    else if (70>percentage && percentage>=60 && coeff>=25){
        var grade=5}
    else if (70>percentage && percentage>=60 && coeff<25){
        var grade=4}
    else if (60>percentage && percentage>=50 && coeff>=20){
        var grade=4}
    else if (60>percentage && percentage>=50 && coeff<20){
        var grade=3}
    else if (50>percentage && percentage>=35 && coeff>=10){
        var grade=3}
    else if (50>percentage && percentage>=35 && coeff<10){
        var grade=2}
    else if (35>percentage && percentage>=20 && coeff>=10){
        var grade=2}
    else if (35>percentage && percentage>=20 && coeff<10){
        var grade=1}
    else if(percentage<=19 && percentage>0){
        grade=1}
    else{grade=0}
    
    var goodImg='&#9733;'
    var badImg='&#9760;'
    
            
    for(var j=0;j<grade;j++){
            gs+=(goodImg+' ')
            }
    if(grade==0){
        stars='Unclassified '+badImg}
    else{stars=gs}
    }
//--------------------------------------------------------------------------------------------------------
myWin= open("",“cert_window”,“width=760,height=500,status=no,toolbar=no,menubar=yes,scrollbars=1”);
myWin.document.write(’’);
myWin.document.write(‘Certificate of Achievement’);
var test=document.title
myWin.document.write(’’);
myWin.document.write(’’);
myWin.document.write(’’);
myWin.document.write(’’);
myWin.document.write(’’);
myWin.document.write(’
‘);
myWin.document.write(’
’);
myWin.document.write(‘

Certificate of Achievement​

’);
myWin.document.write(’
This is to certify that:’+name+’
Has completed:’);
myWin.document.write(’
’+test+’
Statistical analysis to follow:
’);
myWin.document.write(’


’);
myWin.document.write(‘ ’);
myWin.document.write(’ ’);
myWin.document.write(‘

‘);
myWin.document.write(‘

Number of questions set:’+numq+’
Number of questions attempted:’+total+’
Number of questions correct:’+correct+’
Time allowed:’+setting+’
Time taken:’+time+’
Quality coefficient:’+coeff+’
Percentage:’+percentage+’
Grade:

’);
myWin.document.write(‘

’);
myWin.document.write(‘

’);
myWin.document.write(‘

’);
myWin.document.write(‘

’);
myWin.document.write(‘

’);
myWin.document.write(‘

’);
myWin.document.write(‘

’);
myWin.document.write(‘
’);
Code:
    if(grade==0){imgClass="faceClass"}
    else{imgClass="starClass"}
    
    myWin.document.write('<td class="'+imgClass+'" align="left">'+stars+'</td></tr></table>');
    myWin.document.write('<br />');
    
    myWin.document.write('<table width="600" border="0" cellspacing="0" cellpadding="4">');
    myWin.document.write('<tr><td class="td2" colspan="2"> <hr noshade size="1" width="540"></td></tr>');
    myWin.document.write('<tr><td width="260">&nbsp;</td><td  width="300"></td></tr>');
    myWin.document.write('<tr><td  width="260" class="td2">Date and time of test:</td><td width="300" class="td2">'+Date()+'</td></tr>');
    myWin.document.write('<tr><td  width="260">&nbsp;</td><td width="300">&nbsp;</td></tr>');
    myWin.document.write('<tr><td  width="260" class="signature">Signature:</td><td width="300"></td></tr>');
    myWin.document.write('<tr><td width="260">&nbsp;</td><td  width="300"></td></tr>');
    myWin.document.write('<tr><td width="260">&nbsp;</td><td  width="300"></td></tr>');
    myWin.document.write('</table>');
    
    myWin.document.write('<table width="100%" border="1" cellpadding="10" class="InnerTable2"><tr><td>');
    myWin.document.write('<p class="tom">This analysis is for guidance only</p>');
    myWin.document.write('<p class="tom">Colourful Solutions for Chemistry</p>');
    myWin.document.write('<p class="tom"> &copy; IsisSoft 2012</p></td></tr></table></td></tr></table>');
    myWin.document.write('</table>');
    myWin.document.write('');

    // close the document - (not the window!)
    myWin.document.close();
}
 
I suppose that the bug is due to window.document.open(). It seems to deal with popups and popups are only partially supported in HTMLEXE. Try to modify your code to open the window with the dedicated JavaScript function window.external.ShowPopup, as explained in the doc at http://www.htmlexe.com/help/popupwindows
 
Back
Top