2

コードは次のとおりです。-

    <script type="text/javascript">

var timer = 150;
var currentWindow;
$(document).ready(function() 
{
    $("#creditme").button({
        icons: { primary: "ui-icon-check" }
    }).hide();
    $("#viewad").button({
        icons: { primary: "ui-icon-play" }
    }).hide();
    $("#progressbar").progressbar({value: 0}).hide();

    var time;
    var id;
    var title;
    var url;

    $('.googlep-advertisement').bind('click', function()
    {       
        id = $(this).attr('id');
        title = $(this).text();
        url = $('#yturl-'+id).text();
        timer = $('#ytime-'+id).text();
        $("#dialog-message").dialog({
            modal: true,
            width: 700,
            title: title,
            resizable: false,
            draggable: false,
            beforeClose: function() { clearAd(); }
        });
        if (!$("#progressbar").is(":visible") && !$("#creditme").is(":visible")) 
        {
            $("#viewad").show();
        }
    });


    $("#viewad").bind('click',function() {
       $.get("googlep_credit.php" + '?start=' + id);
       $("#viewad").hide();
       $("#progressbar").progressbar('value', 0).show();
       currentWindow = window.open(url, 'videoad', 'height=480,width=640', false);
       window.blur();
       window.focus();
       progresscount(timer);
    });
    $("#creditme").click(function() {
        $.get("googlep_credit.php" + '?id=' + id);
        $("#creditme").hide();
        $("#dialog-message").dialog('close');
        $("#"+id).parent().parent('tr').fadeOut('slow');
    });
    function progresscount(time) 
{
    if(time == 0) 
    {
        if(isWindowClosed() == true)
        {
            alert('You closed the popup before timer reached zero or you are using popup-blocking software.');  
            $("#dialog-message").dialog('close');
        }
        else
        {
            $("#creditme").html('<g:plusone callback="plusone_vote" href="'+url'"></g:plusone>');
            $("#creditme").show();
        }   
        $("#progressbar").hide();
    } 
    else 
    {
        time--;
        $("#progressbar").progressbar('value', parseInt((timer - time) * 100 / timer));
        setTimeout(function() { progresscount(time) }, 100);
    }
}
});

function isWindowClosed()
{
    if (!currentWindow || typeof currentWindow == 'undefined' || currentWindow && currentWindow.closed) 
    {
        return true;
    }
    else
    {
        return false;
    }
}



function clearAd()
{

}
</script>
<style>
.dialog-message {

}
</style>

<div id="dialog-message" class="dialog-message" title="View Video" style="display:none">
    <p>

        <center>
            <button id="viewad" style="ui-helper-hidden">Click here to view the video</button>
            <div id="progressbar"></div>
            <button id="creditme" style="ui-helper-hidden">Test</button>
        </center>
    </p>
</div>

コードに問題はありません。問題は次のとおりです。- http ://dl.dropbox.com/u/14384295/70.jpeg

google chrome inspect elementでチェックすると、コードは http://dl.dropbox.com/u/14384295/71.jpegとして表示されます。

正しく機能している場合は、> http://dl.dropbox.com/u/14384295/72.jpegと表示されます。

その部分にあるグーグルjsによってコードが変換されていないようです。混乱してしまったらごめんなさい。

'url'varの追加を間違って行っている可能性があります

4

1 に答える 1

2

私はあなたの問題がこの行にあるとかなり確信しています:

$("#creditme").html('<g:plusone callback="plusone_vote"></g:plusone>');

Google +1スクリプトの実行後に要素を動的に追加し<g:plusone>ているため、何も起こりません。

これを解決するには、最初からHTMLに+1マークアップを配置して、+ 1スクリプトがそれを見つけてレンダリングできるようにし、表示する$("#creditme").show();必要がある場合にのみ呼び出します。

<button id="creditme" style="ui-helper-hidden">
    <g:plusone callback="plusone_vote"></g:plusone>
</button>

ページの読み込み後にURLを動的に変更する場合は、Googleのドキュメントの例を確認してください。ボタンを明示的にロードできるようになります。

于 2011-07-14T15:54:04.773 に答える