2015-09-06 77 views
0

由於某些原因,此zeroclipboard實現只在我刷新頁面的一半時間內工作。它在https頁面上充當https。一個有趣的事情是,我可以告訴我什麼時候刷新頁面,它不會工作,因爲bit.ly鏈接似乎最初變成藍色(默認的a-link顏色),然後立即切換到我的style.css設置。zeroclipboard工作時間的一半時間

<script src="./js/jquery-2.1.3.min.js" type="text/javascript"></script> 
<script src="./js/ZeroClipboard.js" type="text/javascript"></script> 
<script src="./js/zeroclip.js"></script> 

這裏是我的zeroclip.js的內容:

ZeroClipboard.setMoviePath('http://www.ultrasoundoftheweek.com/clipshare/js/ZeroClipboard10.swf'); 
var clip2 = new ZeroClipboard.Client(); 
jQuery(document).ready(function() { 
    clip2.addEventListener('mousedown', function() { 
     var alltext = $('#result').text(); 
     clip2.setText(alltext); 
    }); 
    clip2.addEventListener('complete', function() { 
     $("#copybutton").html("<font color=\"#434343\"><strike>Copy Link to Clipboard</strike></font><font color=\"#D00000\"> Copied</font>"); 
     //alert('Copied'); 
    }); 
    clip2.glue('copyplain'); 
}); 

HTML:

<h2 align="center">ULA ClipShare Uploader</h2> 
<br> 
<div style="overflow: hidden;"> 
<div class="topbox"> 
<h4 class="textl"><a href="https://www.ultrasoundoftheweek.com/clipshare/share.php?&f=e1cQsRltii" >http://bit.ly/1JKAAuJ</a></h4> 
<h4 class="textr">Email this Link</h4> 
<div class="clear"></div> 
<div class="topbox"> 
<div class="textl" id="copyplain"><button id="copybutton">Copy Link to Clipboard</button></div> 
<div id="result" class="result" style="display:none;">http://bit.ly/1JKAAuJ</div> 

CSS:

body { 
    height: 100%; 
    width: 100%; 
    text-align: center; 
} 
#centerContainer { 
    height: auto; 
    min-height: 100%; 
    max-width: 900px; 
    text-align: left; 
    margin: 0px auto; 
    padding-left: 5px; 
    padding-right: 5px; 
} 
P { 
    FONT-SIZE: 8pt; 
    COLOR: #000000; 
    FONT-FAMILY: Oxygen 
} 
TD { 
    FONT-SIZE: 8pt; 
    COLOR: #000000; 
    FONT-FAMILY: Oxygen 
} 
h2 { 
    FONT-FAMILY: Oxygen 
} 
h4 { 
    FONT-FAMILY: Oxygen 
} 
.topbox { 
    display: table; 
    width: 100%; 
    height: auto; 
    margin: 0px 0px; 
} 
.topbox .textl { 
    display: table-cell; 
    height: 32px; 
    vertical-align: middle; 
    display: inline-block; 
} 
.topbox .textr { 
    display: block; 
    float: right; 
} 
.topbox .clear { 
    clear: both; 
} 
#copyplain { 
    position: absolute 
} 
#copywrite { 
    clear: both; 
    position: relative; 
    z-index: 10; 
    height: 3em; 
    margin-top: -3em; 
} 

回答

0

萬一別人遇到這個問題,經過一小時的修補後,我能夠解決它。如果我把<script src="./js/zeroclip.js"></script>行放在</body>的上面,代碼工作正常。我猜是因爲某種原因,它不喜歡我的jQuery(document).ready(function()