/    Sign up×
Community /Pin to ProfileBookmark

Track button click within a iframe

Hello,

I was just wondering, is it somehow possible to track a form submission button click within an iframe?

For example:

[B]index.php[/B]

[code=php]<html>
<head>
<title>Test</title>
<script>
function callBackFunction()
{
// call this function if user clicks the submit button within iframe
}
</script
</head>
<body>
<iframe src=”form.php”></iframe>
<!– JavaScript here to track button click within iframe –>
</body>
</html>[/code]

[B]form.php[/B]

[code=php]<html>
<head>
<title>Form</title>
</head>
<body>
<form action=”formProcess.php” method=”post”>
<input type=”text” name=”nick” id=”nick” />
<input type=”submit” value=”Login” name=”cmd” id=”cmd” />
</form>
</body>
</html>[/code]

Any ideas anyone?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Jun 10.2008 — The iframe has to be in your domain to begin with.

On the form you can add an onclick handler and reference a function in the parent page.

onclick="parent.functionName()"

If you want to add the onclick from the parent, it is sort of a guessing game on when the page is loaded.

Eric
×

Success!

Help @latheesan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...