Javascript onload没有在IE中触发 [英] Javascript onload not firing in IE

查看:71
本文介绍了Javascript onload没有在IE中触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个有两个div标签和两个单选按钮的网站。 div将根据所选的单选按钮显示。在页面加载时,我从主页面传递单选按钮的值,因此我显示div。它适用于chrome和firefox,但在IE中显示出问题。我正在使用IE 11.我没有尝试过其他版本的IE。我的代码如下:

I am creating a website which has two div tags and two radio buttons. The div is to be displayed on the basis of radio button selected. On page load I pass the value of radio button from main page and accordingly I display div. It works well with chrome and firefox but showing problem in IE. I am using IE 11. I have not tried with other versions of IE. My code is as follows:

<asp:RadioButton ID="mail_stat" Text="Mailwise Statistics" runat="server" GroupName="stat_select" onclick="ch(1)" ClientIDMode="Static" />
   <asp:RadioButton ID="aggegrate_stat" Text="Aggegrate Statistics" runat="server" GroupName="stat_select" onclick="ch(2)" ClientIDMode="Static" />







<div id="first">
    <table border="0">
        <tr>
            <td>
                         
                <asp:Label ID="lbl_pro_id" runat="server" Text="Promotion Id"></asp:Label> </td>
            <td>
                   
                <asp:TextBox ID="txt_pro_id" runat="server" Width="101px"></asp:TextBox></td>
        </tr>
        <tr>
            <td>
                         
                <asp:Label ID="lbl_sub" runat="server" Text="Subject"></asp:Label></td>
            <td>
                   
                <asp:TextBox ID="txt_sub" runat="server" Width="301px" Height="16px"></asp:TextBox></td>
        </tr>
    </table>
</div>







<div id="second">
    <table border="0">
        <tr>
            <td>
                        
                <asp:TextBox ID="txtStartDate" runat="server" required="true" placeholder="Start Date"></asp:TextBox></td>
            <td>
                <asp:TextBox ID="txtEndDate" runat="server" required="true" placeholder="End Date"></asp:TextBox></td>
        </tr>
    </table>
</div>





我的java脚本如下:



My java script is as follows:

 <%--Javascript for radiobuttion on load--%>              
<script type="text/javascript">
    onload = function () {
        if (mail_stat.checked == true)
        {
            ch(1);
        }
        else if (aggegrate_stat.checked == true)
        {
            ch(2);
        }
    }
</script> 

<%--Javascript for radiobuttion--%>
 <script type="text/javascript">
     $('#first').hide();
     $('#second').hide();
     $('stat2').hide();
     function ch(id) {
         if (id == '1') {
             $('#first').show();
             $('#second').hide();
             $('#stat2').hide();
         }
         else if (id == '2') {
             $('#first').hide();
             $('#second').show();
             $('#stat2').show();
         }
     }
 </script> 



谢谢。


Thank you.

推荐答案

' #first')。hide();
('#first').hide();


' #second')。hide();
('#second').hide();


' stat2')。hide();
function ch(id){
if (id == ' 1'){
('stat2').hide(); function ch(id) { if (id == '1') {


这篇关于Javascript onload没有在IE中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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