Refresh div on parent page from iframe using jquery

I am using fancybox modular box with iFrame. If the form from iFrame succeeds, I use the following code:

<script type="text/javascript">
window.setTimeout('window.top.location.href = "/page.asp"; ',999);
</script>

<script language="javascript">
<!--
setTimeout("parent.$.fancybox.close();",1000)
//-->
</script>

This closes the fancybox modal block and refreshes the parent page. I want to target div for refresh on parent page from iFrame using jQuery.

I want the DIV target on the parent page with id = "target" to be updated, not the whole page. How do I do this using jQuery?

TIA

Code example below

Parent page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
</head>
<body>
<div id="target">
content content
</div>
</body>
</html>

IFrame page after form validation

<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
</head>

<script type="text/javascript">
window.setTimeout('window.top.location.href = "/parent_page.asp"; ',999);
</script>

<script language="javascript">
<!--
setTimeout("parent.$.fancybox.close();",1000)
//-->
</script>

How to create a function on the parent page to update div id = "target" and call it from an iFrame. Now the entire parent page is being updated.

+3
source share
2

jQuery

window.setTimeout('window.top.location.href = "/page.asp"; ',999); :

window.setTimeOut(function(){
    $("#target", window.parent).load("/page.asp #target");
},999);
+3

, javascript , iframe.

window.parent.myFunctionInParent('my param');

iframe.

, .

0

All Articles