This is a migrated thread and some comments may be shown as answers.

Access a tab javascript variable from parent...

1 Answer 102 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Luciano Kaesemodel
Top achievements
Rank 1
Luciano Kaesemodel asked on 03 Mar 2011, 08:18 PM
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

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 09 Mar 2011, 10:36 AM
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!
Tags
TabStrip
Asked by
Luciano Kaesemodel
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or