dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Please Help

  1. #1
    Join Date
    Jul 2011
    Location
    Islamabad
    Posts
    2

    Please Help

    Hi friends,

    Please visit this page to see what i am doing. www.qurantutoring.vndv.com/website_visitor.html

    I want that whenever i click the next button the website from the array should open into the iframe named as "browser". and whenever i click back the previous array item(website) should open in the iframe.
    I have done this in previous projects but don't know what i am missing today , your help will be greatly appreciated. Thanks


    <html>
    <head>
    <title>Webpage visitor</title>
    <script type="text/javascript">

    function init()
    {
    var blogs=new Array(); // regular array (add an optional integer
    var i=0;
    var maximum=2;
    blogs[0]="google.com";
    blogs[1]="yahoo.com";
    blogs[2]="youtube.com";
    }

    function back()
    {
    alert('hello');
    if(i>0)
    {
    i=i-1;
    document.getElementById('browser').src = blogs[i];
    }
    else
    {

    }
    document.forms["myform"].submit();
    }


    function next()
    {
    if(i<maximum)
    {
    i=i+1;
    document.getElementById('browser').src = blogs[i];
    }
    else
    {

    }
    }

    </script>

    </head>

    <body onload="init()">

    <form action="google.com" target="browser" id="myform">
    <input type="text" name="url" size=80>
    <input type="button" value="Back" onclick="back();">
    <input type="button" value="Next" onclick="next();">
    </form>

    <iframe width=1000 height=500 name="browser" id="browser" src=""></iframe>

    </body>
    </html>

    Waiting for any help.

  2. #2
    Join Date
    May 2011
    Posts
    194

    local vars

    Hi,

    function init()
    {
    // you declare local vars for this function
    // outside of function this vars not exist

    // init should set global vars to value (thats why init methode)

    var blogs=new Array(); // regular array (add an optional integer
    var i=0;
    var maximum=2;
    blogs[0]="google.com";
    blogs[1]="yahoo.com";
    blogs[2]="youtube.com";
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles