jQuery and IE not playing nice

Posted by Neurofluxation on Stack Overflow See other posts from Stack Overflow or by Neurofluxation
Published on 2011-01-11T11:41:53Z Indexed on 2011/01/11 11:53 UTC
Read the original article Hit count: 280

Filed under:
|

Hello, I have this section of code:

function createDownload() {
        var category, format, specification, download;

        $('#submitform').click(function() { 
            category = $('#cate').val(); 
            format = $('#form').val(); 
            specification = $('#spec').val(); 

            if (category == "NULL" || format == "NULL" || specification == "NULL") { 
                alert("Please select all options.");
                return false;
            } else {
                download = "pdfs/"+specification+format+category+".pdf"; 
                window.open(download);
            }
        });
    }

Now... In Internet Explorer it says there is an "Error on the page" - Message: 'return' statement outside of function and I have to click the button again.

In Firefox, Chrome and Safari - I have to click the button twice to get the PDF to appear... (and no errors)...

Now why could that be?!

As per request - My Form declaration: <form method="post" action="javascript: return false;" onSubmit="createDownload();">

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery