
Untitled
By: a guest on
Jun 22nd, 2012 | syntax:
None | size: 1.35 KB | hits: 13 | expires: Never
Ajax simulating a click
<script type="text/javascript" language="javascript">
//<![CDATA[
function FriendCenterObject() {
var fcAction = function(actionUrl, gamerTag, responseHandler) {
responseHandler = responseHandler || function(response) {
if (response.status != 0) {
DisplayMessageDialog('Error', response.view, 'Close', null, MessageLevelType.Error);
}
else {
DisplayMessageDialog('Message', response.view, 'Close', FriendCenter.RefreshContentAction);
}
}
$.post(actionUrl, { 'gamerTag': gamerTag }, responseHandler);
};
this.AddFriend = function(gamerTag) {
gamerTag = $.trim(gamerTag); // trim leading and trailing whitespaces
if (gamerTag != "") {
fcAction('/en-US/FriendCenter/SendFriendRequest', gamerTag);
}
return false;
};
this.RefreshContentAction = function(){};
};
var FriendCenter = new FriendCenterObject();
//]]>
</script>
<a href="#" onclick="FriendCenter.AddFriend('mirco')">Add to Friends List</a>
jQuery("#iframeID").src = "path/to/site";
//getting the content window html tag.
var iFrame = document.getElementById("iframeID").contentWindow;
jQuery(iFrame.body).find("#someID").click();