2011-10-27 7 views
-1

ウェブマスターが自分のサイトにスニペットを挿入できるようにするjsスニペットを作成した後、htmlを作成します要素(おそらくボタン)をクリックし、クリックすると自分のサイトにURLとタイトルを投稿し、新しいウィンドウで自分のサイトを開き、ユーザーはurl +タイトルを自分のリストの新しい項目として見ることができます。fb apiやツイートフィードなどのリモートサイトで再利用できるjsスニペットを作成する方法

Facebookはフィードを使ってこのような箱やツイッターを使っていますが、これは実際どのように行われますか?

+1

に設定a'sターゲット上のhrefへtitle and urlを追加します無効にされていますか?恐ろしい最初の記事で説明した。 – OptimusCrime

答えて

1

私はcorrectalyあなたを理解していれば、 一つの方法は、あなたの処理のページへのURLで、現在のページのURL location.hrefとタイトルdocument.titleを渡すことによってでしょう、そしてあなたは、抽出に要求されたURL

のための報復と場所の値を検証します
<script> 
    function opens(){ 
    var j,w,s,u; 
    j=document.title; 
    w=j.replace(/"/g,'%22'); 
    w=j.replace(/&/g,'%26'); 
    u = "tit="+w+"&location="+encodeURIComponent(location.href); 
    var nwin = window.open("landingpage.php?"+u, "subWindow", "height=400,width=700");   
    } 


    function placeButtonWhatEver(ButtonText){ 
    var eml = document.createElement("span"); 
    var tex = document.createTextNode(ButtonText); 
    eml.appendChild(tex); 
    eml.onclick= opens; 
    document.body.appendChild(eml); 

    // FOR you to do think about it ; depends how you implement it; 
    // if there is a <A> which could be after the empeded script 
    // remove the next child say a link with hardcoded title and url values 
    // 
    } 

    </script> 


    <script>placeButtonWhatEver('Click Vote to like This')</script><!-- <a href="landingpage.php?tit=pagetitke&location=http"></a> --> 

あなたはそれがまだJavaScriptで作業したい場合は、あなたが共有下のいくつかの並べ替えを探しているあなたは_blank

関連する問題