I have a parent page where I am submiting a form and calling two funcions on_click of the submit button. One function from the same page and another from child page.
I am wondering how to call a Javascript funcion on the parent page from the child page to post on a Facebook wall. This is my application.
My parent.php:
<form action="child.php" method="post">
<input type="text" value="$result" name="codebox">
<input type="submit" onclick="funcion codeload();function postToFeed();"/>
</form>
My child.php:
<body>
<?PHP
$son=$_REQUEST['codebox'];
session_start();
$_SESSION['sony'] =$son;
$ashutosh=$_SESSION['sony'] ;
$tinyurl = file_get_contents("http://tinyurl.com/api-create.php?
url=http://www.ebhasin.com/approval/files/main.php?a=$ashutosh");
$desc='Place here description what you want';
?>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p id='msg'></p>
<script>
FB.init({appId: "313877282043416", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: '<?PHP echo $tinyurl?>',
picture: 'http://www.dogoscanarios.com/en/themes/dogotheme/images/icon_dot_cat.gif',
name: 'Drum Precussion',
caption: ' I just created a new Drum Loop using Drum Beats Pro! Come listen to it!',
description: '.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
Well if lets say the parent window opens a child popup window, then do as following
EDIT :
Your parent page, parent.php
First link opens popup window, second link calls the function
postToFeed()in popup window from parent.Your child popup window, child.php
This function in popup window is called after you click the link in parent window.
Hope This helps!