Parker
Parker

Reputation: 123

iPhone Web App Div Tag Reloading in Safari

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

Answers (2)

searlea
searlea

Reputation: 8378

Does adding return false; to the end of showhide help?

Upvotes: 0

No one in particular
No one in particular

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

Related Questions