Access a tab javascript variable from parent...

2 posts, 0 answers
  1. Luciano Kaesemodel
    Luciano Kaesemodel avatar
    29 posts
    Member since:
    Apr 2007

    Posted 03 Mar 2011 Link to this post

    Hello...

    I have a main page with a lot of content and a RadTabStrip with 2 tabs... 
    I load a local page on my Tab. That page has a javascript variable called "map"

    So,  In main page I have a html button. When the user click it I´m supposed to get the Iframe variable "map" (from tab) and play with it...
    How can I get that variable ?

    Thanks
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 09 Mar 2011 Link to this post

    Hi Luciano,

    You  could access variable in iframe, using the name of the iframe followed by dot notation and the name of the variable. Consider the following example:
    Copy Code
    Document 1:
     
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <iframe name="ifrOne" src="[i]your_file.htm[/i]"></iframe>
    <p>
    <br />
    <a href="#" onclick="alert(window.ifrOne.test_var);return false;">check variable</a>
    </p>
    </body>
    </html>
     
    Document 2 (the one the iframe src points to):
     
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
        var test_var = "testing, testing . . .";
    </script>
    </head>
    <body>
    <div style="height:200px;width:300px;background:#dee;"></div>
    </body>
    </html>


    All the best,
    Dimitar Terziev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top