SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    iframe button that adds a value to parent variable

    Hello,

    I am trying to write a script that allows a button in an iframe to change the value of a variable that is in the parent page. I then want to have an if statement in the parent that will change the url of the iframe ( or even change the url of the parent)

    Here's what I have for the parent:

    HTML Code:
    <html>
    <head>
    <iframe src="http://zaazoo.thewebbusters.com/button.html">
    </iframe>
    </head>
    <body>
    <script type="text/javascript">
    var a=0
    function addToA () {
    	a=(a+1)
    }
    if(a==1) {
    	window.location="http://www.google.com"
    }
    }
    </script>
    </body>
    </html>
    here's what I have for the iframe

    HTML Code:
    <html>
    <head>
    </head>
    <body>
    <div style=" position: absolute; left:80; top: 35;">
    <input type="button" onclick="parent.addToa()" value="Next">
    </div>
    </body>
    <html>
    I figured this script should change the parent to the url, but it doesn't. Does anyone know what event I could use to change the iframe url? the parent url?

    Thanks again for all your help,
    Dave
    Last edited by Mittineague; Aug 14, 2011 at 11:38. Reason: reformatting bbcode tags


Tags for this Thread

Bookmarks

Posting Permissions

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