简体   繁体   中英

JavaScript not firing in other browsers than Opera

I have a problem I'm battling with, I started seeing that my logs have started showing users not logging in so I started checking and noticed that the new login frame don't become visible in any other browser than Opera.

I know that the div can be visible, if I remove display:none the box shows as it should in all browser, so my bet is on the JavaScript not firing.

If its of any use the box I'm trying to show is a div frame as shown below but it's laying on top of the page.

<script type="text/javascript">
    function ShowHideRegLog() {
        var box = document.getElementById('LoginReg');
        if (box.style.display === 'none') {
            box.style = 'display:block; position:absolute; top:50%; left:50%; margin:-150px 0 0 -120px; z-index:99;';
        }
        else if (box.style.display === 'block') {
            box.style = 'display:none;';
        }
    }
</script>

<div class="RegFullFrame" id="LoginReg" style="display:none;">
    <div style="color:#defdef; font-size:22px; z-index:99; margin: 0 0 5px 5px; font-weight:bold;">
        Login:
    </div>
    <div class="RegTextFrame">
        <asp:TextBox CssClass="RegTextBox RegTopTexBox" ID="Usertxt" runat="server">
        </asp:TextBox>
        <asp:TextBox CssClass="RegTextBox RegBottomTexBox" style="color:#989898;" ID="Pwdtxt" onfocus="this.value=''; this.type='password'; this.style.color='#000';" runat="server">
            Password
        </asp:TextBox>
    </div>
    <asp:Button CssClass="RegButton" ID="RegButton" runat="server" Text="Login" 
            onclick="Login_Click" OnClientClick="ShowHideRegLog();" />
</div>
<input id="RegButton" style=" background:none; border:none; font-weight:bold; padding-top:6px; color:red;" runat="server" 
        type="button" value="Login" onclick="ShowHideRegLog()" />

Include jquery in <head> and use the following script.

    function ShowHideRegLog() {
        var box = document.getElementById('LoginReg');
        if (box.style.display == 'none') {
            $("#LoginReg").show();
        }
        else if (box.style.display == 'block') {
            $("#LoginReg").hide();
        }
    }  

* Without jquery : *

    function ShowHideRegLog() {
        var box = document.getElementById('LoginReg');
        if (box.style.display === 'none') {
            box.style.display = 'block';
            box.style.position = 'absolute';
            box.style.top = '50%';
            box.style.margin = '-150ps 0 0 -120px';
            box.style.zIndex = '99';
        }
        else if (box.style.display === 'block') {
            box.style.display = 'none';
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM