Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello!!

I have a javascript function to show/hide a [runat="server"] div
it works in all browsers but Safari

javascript function:
JavaScript
<script type="text/javascript">

	    function Show_Hide_Display() {
	        var div1 = document.getElementById('<%=main_filter.ClientID%>');

		    if (div1.style.display == "" || div1.style.display == "block") {
		        div1.style.display = "none";
		    }
		    else {
		        div1.style.display = "block";
		    }
		    return false;
		}

	</script>


calling the javascript function:
HTML
<pre><div class="col-md-6 col-xs-3 pull-right btn-mobile">
	<input type="button" class="btn btn-primary btn-block span3" id="closefilter" value="Done" onclick="Show_Hide_Display()" />
</div>


please advise

What I have tried:

I tried to use JQuery but still the same:
JavaScript
$(document).ready(function () {
           $("#closefilter").click(function () {
               $("main_filter").hide();
           });
       });


removed the (IF) statement from the JavaScript function but still the same.
used
document.getElementByClassName
but the same as well!!
Posted
Comments
A_Griffin 8-Nov-17 18:52pm    
A couple of possibilities here:
https://stackoverflow.com/questions/10366/style-display-not-working-in-firefox-opera-safari-ie7-ok

1. This worked for me with a similar problem, where Safari didn't set the display to block: My fix was to do
document.getElementById('editRow').style.display = ''; followed by
document.getElementById('editRow').style.display = 'block'; - tested on IE11, Chrome, Safari

2. won't displa properly here, but read the stackoverflow page - ans about replacing the page declarations

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900