www.webdeveloper.com
Results 1 to 1 of 1

Thread: Calling a javascript file off domain?

  1. #1
    Join Date
    Nov 2008
    Posts
    5

    Calling a javascript file off domain?

    Hi All:

    I'm trying to write a wordpress plugin that incorporates baseball-reference.com's B-R Linker functionality with my wordpress installation (if you follow the link - the B-R Linker is currently just a bookmarketlet - I want to have it ran automatically when hitting submit); however it does not seem to be working:

    I tried to bind the javascript code to the "Submit" button on Wordpress to no avail; however if I replace the sr_link function's code with 'alert("Testing");' it works - I believe it may be an intentional "defect" of javascript to not allow running off domain scripts. If this is the case - is there any way to get around this? or can anyone tell if I am doing anything wrong? Thanks so much.

    -MS

    Code:
       function sr_link() { 
           var s=document.createElement("script");
           s.charset="UTF-8";
           var rand_param =    "rand=" +  Math.floor(Math.random()*10000);
           s.src="http://baseball-reference.com/linker/linker.js?"+ rand_param;
           void(document.body.appendChild(s));
       }
    
    
     jQuery(document).ready(function() {
        
        
        jQuery('#publish').bind('click', function() 
          {
          jQuery("#edButtonHTML").click();
          sr_link();  
        
        
          }); 
      });
    Last edited by Kor; 08-09-2010 at 08:14 AM. Reason: it is JQuery

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles