jQuery和IE的播放效果不佳 [英] jQuery and IE not playing nice

查看:102
本文介绍了jQuery和IE的播放效果不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码:

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);
            }
        });
    }

现在...在Internet Explorer中,它说页面上有错误"-Message: 'return' statement outside of function,我必须再次单击该按钮.

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.

在Firefox,Chrome和Safari中-我必须单击两次按钮才能使PDF出现...(并且没有错误)...

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

现在为什么会这样?!

根据请求-我的表单声明: <form method="post" action="javascript: return false;" onSubmit="createDownload();">

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

推荐答案

您需要更改action='javascript: return false;'并删除onsubmit.它应该变成action='javascript: createDownload();'

You need to change your action='javascript: return false;' and remove the onsubmit. It should become action='javascript: createDownload();'

这篇关于jQuery和IE的播放效果不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆