2011-07-14 89 views
2

以下是代码: -Google+按钮没有出现

<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

在与谷歌浏览器检查检查元素,将出现 代码为 http://dl.dropbox.com/u/14384295/71.jpeg

正常工作,将显示为>http://dl.dropbox.com/u/14384295/72.jpeg

看来这个代码是不是被由该部分中的Google js转换。如果我一直困惑,我很抱歉。

我可以大概做加法的“网址” VAR错误

+0

你贴了相同的图像3次,fyi。 – Phil

+0

对不起,编辑它。 – friendishan

+0

只是想让你知道:D – Phil

回答

2

我敢肯定,你的问题就出在这行:

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

你在谷歌后动态添加<g:plusone>元素+1脚本已经运行,所以没有任何反应。

要解决这个问题,只需从头开始将+1标记放在html中,以便+1脚本可以找到并呈现它,并且只需在显示它时调用$("#creditme").show();即可。

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

如果要动态地更改页面加载后的URL,check out the examples from the Google documentation。它将允许您明确加载按钮。

+0

仍然dosen't工作..我会动态地添加'网址'变种。 – friendishan

+0

我打算假设你包含+1脚本? ''。如果你是,什么实际上不工作?它没有显示出来吗? –

+0

对不起,我的意思是说,它会工作,并确实有效。 是的,我包括+1脚本> 我的意思是我需要动态添加'url'var,编辑一个问题 – friendishan