Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 22nd, 2012  |  syntax: None  |  size: 1.35 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Ajax simulating a click
  2. <script type="text/javascript" language="javascript">
  3. //<![CDATA[
  4.     function FriendCenterObject() {
  5.         var fcAction = function(actionUrl, gamerTag, responseHandler) {
  6.             responseHandler = responseHandler || function(response) {
  7.                 if (response.status != 0) {
  8.                     DisplayMessageDialog('Error', response.view, 'Close', null, MessageLevelType.Error);
  9.                 }
  10.                 else {
  11.                     DisplayMessageDialog('Message', response.view, 'Close', FriendCenter.RefreshContentAction);
  12.                 }
  13.             }
  14.             $.post(actionUrl, { 'gamerTag': gamerTag }, responseHandler);
  15.         };
  16.         this.AddFriend = function(gamerTag) {
  17.             gamerTag = $.trim(gamerTag); // trim leading and trailing whitespaces
  18.             if (gamerTag != "") {
  19.                 fcAction('/en-US/FriendCenter/SendFriendRequest', gamerTag);
  20.             }
  21.             return false;
  22.         };
  23.         this.RefreshContentAction = function(){};
  24.     };
  25.     var FriendCenter = new FriendCenterObject();
  26. //]]>
  27. </script>
  28.        
  29. <a href="#" onclick="FriendCenter.AddFriend('mirco')">Add to Friends List</a>
  30.        
  31. jQuery("#iframeID").src = "path/to/site";
  32.        
  33. //getting the content window html tag.
  34. var iFrame = document.getElementById("iframeID").contentWindow;
  35. jQuery(iFrame.body).find("#someID").click();