JSやJqueryについてはよくわからないので、助けていただければ幸いです。基本的に、固定URLではなくランダムURLを使用したいと思います。ランダムなURLは、外部のフラットテキストファイルhttp://example.com/url100.txtから取得できます。
htmlページのセクション内で使用している現在のコードは次のとおりです
<script type='text/javascript'>
//<![CDATA[
var mylinks = "http://google.com";
jQuery(document).ready(function ($) {
$('#default-usage .to-lock').sociallocker({
buttons: {order:["facebook-like","twitter-tweet","google-plus"]},
twitter: {url:"http://google.com"},
facebook: {url:"http://google.com"},
google: {url:"http://google.com"},
text: {
header: "Like us To Unlock This Content",
message: "This content is locked. Like us on Twitter, Facebook or Google plus to unlock it."
},
locker: {close: false, timer: 0,},
theme: "secrets"
});
});
//]]>
</script>
つまり、基本的にTwitterの代わりに:{url: " http://example.net "}、ランダムなURLを使用したいと思います。私の質問がはっきりしていることを願っています
これを試して:
// Make sure the file is on the same server.
var file = "http://example.com/url100.txt";
$.get(file,function(txt) {
// Split data and convert it into array
var lines = txt.responseText.split("\n");
var link = lines[Math.floor(Math.random() * lines.length)];
// Apply plugin here
$('#default-usage .to-lock').sociallocker({
buttons: {order:["facebook-like","twitter-tweet","google-plus"]},
twitter: {url:link},
facebook: {url:link},
google: {url:link},
text: {
header: "Like us To Unlock This Content",
message: "This content is locked. Like us on Twitter, Facebook or Google plus to unlock it."
},
locker: {close: false, timer: 0,},
theme: "secrets"
});
});
あなたが言ったように、あなたはそれをBLOGSPOTで使用していて、テキストファイルは別のサーバーに存在します。次に、このソリューションを使用します。
jQuery(document).ready(function ($) {
// Add link one by one in ""
var social_links = ["link1", "link2", "link3", "link4", "link5", "link6"];
var link = social_links[Math.floor(Math.random() * social_links.length)];
console.log(link);
// Apply plugin here
$('#default-usage .to-lock').sociallocker({
buttons: {order:["facebook-like","twitter-tweet","google-plus"]},
twitter: {url:link},
facebook: {url:link},
google: {url:link},
text: {
header: "Like us To Unlock This Content",
message: "This content is locked. Like us on Twitter, Facebook or Google plus to unlock it."
},
locker: {close: false, timer: 0,},
theme: "secrets"
});
});
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加