2010-01-01 2 views
1

javascript를 사용하여 요청 양식 콘텐츠를 사용자 정의하고 싶습니다. 는Javascript를 사용하여 fb : request-form의 내용을 동적으로 수정하는 방법은 무엇입니까?

<div id="invite"> 
<fb:serverfbml style="width: 600px; height: 650px;"> 
    <script type="text/fbml"> 
     <fb:request-form 
      action="index.php" 
      method="POST" 
      invite="true" 
      type="MyApp" 
      content="Please have a look at my new __DYNAMICNAME_HERE__. 
       <fb:req-choice url='http://apps.facebook.com/myapp/' label='View Now!' />" > 

      <div class="clearfix" style="padding-bottom: 10px;"> 
       <fb:multi-friend-selector condensed="true" style="width: 600px;" /> 
      </div> 
      <fb:request-form-submit /></fb:request-form> 
    </script> 
</fb:serverfbml></div> 

나는 동적으로 자바 스크립트를 통해 다른 것으로 _DYNAMICNAME_HERE_을 변경하고 싶습니다 ... 난 내 HTML이이 말.

여기 제가 시도한 것들이 있습니다.

function technique1() 
{ 
    var elem = document.getElementById("invite"); 
    elem.innerHtml = elem.innerHTML.replace("__DYNAMICNAME_HERE__", "MyName"); 
    // show div code... 

    // result is, the current page get's re-rendered inside the div, instead of the FB controls. 
} 

function technique2() 
{ 
    // Delete all code inside the div... then construct the content using javascript. 

    var elem = document.getElementById("invite"); 
    elem.innerHtml = text;// text is the div innerHtml code constructed at runtime. 

    // run show div code 
    // result is nothing shows. 
} 

function technique3() 
{ 
    // First, we remove all code from the div 
    // put them into another php page called invite.php 

    var elem = document.getElementById("invite"); 
    elem.innerHtml = "<iFrame src=\"www.myserver.com/invite.php?name=myname\"></iFrame>"; 

    // run show div code 
    // It works but requires 1 more request to the server. 
} 

누군가가 서버 (invite.php)에 대한 추가 요청을 포함하지 않는 기술을 알고 있습니까? 아마도 FB.XFBML.Host.addElement, 새로 고침 등이 포함될 수 있습니다 ...

Btw, 저는 Google의 Closure를 사용하여 div를 팝업 처리합니다.

감사합니다.

답변

0

실제로는 이러한 조작을 허용하도록 설계되었습니다. 당신은 하나 이상의 fb : request-form을 렌더링하지만, 대부분은 < div>에서 style = "display : none"으로 설정 한 다음 자바 스크립트로 표시되는 것을 변경합니다.

렌더링 시간에 결정해야하는 제한된 선택 사항을 제공하므로 제한적인 해결책이지만 AFAIK는 일단 렌더링되면 html 속성을 얻을 수 없습니다.

1

나는 또한 동일한 문제를 겪고 teepark가 제안한 방식대로 해결했습니다. iframe에서 렌더링되기 때문에 Facebook의 HTML 태그를 변경할 수 없습니다. MY 페이지는 www.____.com에 있고 iframe은 www.facebook.com에 있습니다. 도메인 간 정책으로 인해 해당 iframe의 내용을 변경할 수 없습니다.

관련 문제