-3

Thing I am trying to achieve is as follow

  1. I want to create a single html page cordova app
  2. My page will be single, but I want to show mutiple divs as pages.. (Only divs will be toggled as pages. I dont want to add another html page.)

Is it possible? Please explain me...

following is structure which i wana achieve

<code>
<div class="main-content">
<div class="changing-content">
</div>
<div>
</code>
  • Why are you insisting on simulating multiple pages instead of just actually making multiple pages? – takendarkk Jul 09 '16 at 12:35
  • You can manage two type of format for creating phonegap app either Single Page App or Multiple Pages App, depends on your lengths of pages and javascript management. – Kirankumar Dafda Jul 27 '16 at 10:50

1 Answers1

-1

Here is a sample code for you, try and implement for yourself

<body>
    <div id="index">
        <div onclick="showPage('page1')">Page 1</div>
        <div onclick="showPage('page2')">Page 2</div>
    </div>
    <div id="page1" style="display:none">
        This is page1
        <div class="back" onclick="showPage('index')">Back</div>
    </div>
    <div id="page2" style="display:none">
        This is page2
        <div class="back" onclick="showPage('index')">Back</div>
</div>
</body>
<script>
var ids=['page1','page2','index'];
function showPage(pageId)
{
    for(i=0;i<ids.length;i++)
    {
        if(pageId == ids[i])
        {
            document.getElementById(pageId).style.display = "block";
        }
        else
        {
            document.getElementById(ids[i]).style.display = "none";
        }
    }
}
</script>

Here is a jsFiddle link

Kirankumar Dafda
  • 2,354
  • 5
  • 29
  • 56
  • I think for PhoneGap many people who just judge the questions and answers instead of suggesting solutions. Go to ______, down voters !!! – Kirankumar Dafda Jul 27 '16 at 09:41