Reputation: 123
My iOS Web app is written in HTML and CSS. I have a text link that shows/hides a div layer. It works flawlessly but when I change the visibility of the div tag it reloads the page in safari, rther than displying the div in the webapp . Here is my code to enable the Webapp interface:
<meta name="apple-mobile-web-app-capable" content="yes">
Here is my javascript to display the div tag when a link is clicked:
<script language="javascript">
<!--
var state = 'none';
function showhide(layer_ref) {
if (state == 'block') {
state = 'none';
}
else {
state = 'block';
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = state;
}
}
//-->
</script>
The div layer: content
And Lastly, the link that shows the div:
<a href="#" class="Action" onclick="showhide('optionpanel');">Menu</a>
Upvotes: 0
Views: 576
Reputation: 2672
I think display = 'block'
is defined to show the div and force a reload at the same time. So what you're seeing is how it's meant to work.
To make a div visible without the reload/update you need set the visibility flag instead. Use:
hza.style.visibility = state;
Where state is either 'visible' or 'hidden'.
Upvotes: 1