IFrame\HiddenFleld

  • Thread starter Thread starter gh
  • Start date Start date
G

gh

I have an asp.net page that is being displayed in an IFrame of a html
page. The html site is on a different server than the asp.net page. I
have a value I would like to pass to the html page. Can I store the
value in a hidden field of the asp.net page and access it from the html
page, using js? If not can I pass the value in the url? I am using VS 2008

TIA
 
I have an asp.net page that is being displayed in an IFrame of a html
page.  The html site is on a different server than the asp.net page.  I
have a value I would like to pass to the html page.  Can I store the
value in a hidden field of the asp.net page and access it from the html
page, using js?  If not can I pass the value in the url?  I am using VS 2008

TIA

for example, if you have a button in iFrame aspx page:

<input type="button" onclick="pass_value_to_html();" />

and in your iFrame aspx page:
<script>
function pass_value_to_html()
{
var value_to_pass = "test_value_from_iframe";
window.parent.set_value_from_iframe(value_to_pass);
}
</script>

and in your html page:
<iframe src="asp_page.aspx" />
<script>
function set_value_from_iframe(value_from_iframe)
{
alert( "got value:" + value_from_iframe);
}
</script>


... more at http://www.siccolo.com/articles.asp
 
Hi

lets say the bellow markup is your inner aspx page...

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" id="txtInput" />
<h2 id="yahoo">Inner frame</h2>
</div>
<script>
// window.alert(document.getElementById("yahoo"));
</script>
</form>
</body>
</html>

and This is the page that hold the iframe

<head runat="server">
<title>Untitled Page</title>

</head>
<body onload="afunction()">
<form id="form1" runat="server">
<div>
<iframe id="someframe" src="WebForm1.aspx"></iframe>
</div>
</form>

</body>
<script language="javascript" type="text/javascript">
function afunction()
{
var frame = document.getElementById('someframe'); //this is
your frame
var innerdocument = frame.contentWindow.document; //this is
your frame's inner document
window.alert(innerdocument.getElementById("yahoo"));
}
</script>
</html>

Best of luck

Munna

www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
 
Hello TIA
I have an asp.net page that is being displayed in an IFrame of a html page.
The html site is on a different server than the asp.net page. I have a
value I would like to pass to the html page. Can I store the value in a
hidden field of the asp.net page and access it from the html page, using
js? If not can I pass the value in the url? I am using VS 2008
NO

except you mark _both_ sites with a little javascript, like:

document.domain = '<domain>';

Look at:
- http://www.google.ch/search?hl=de&q=document.domain&meta=
 
Back
Top