Chỉ với 1 đoạn code ngắn và đơn giản, bạn có thể gắn hộp xem truyện cười cho Blog để khách tham quan có thể giải trí khi vào Blog của mình, các truyện này sẽ tự động thay đổi truyện khi bạn load trang và điều đặc biệt là bạn có thể thêm truyện mới do chính mình thiết lập.
Mẫu 1:
Đầu tiên, bạn đăng nhập vào Blog, chọn Thiết kế > thêm tiện ích > thêm HTML/Javacript, sau đó dán đoạn code này vào:
Mẫu 2:
- Tạo một widget HTML/JS. Đặt tên theo ý bạn, ví dụ: Truyện cười chọn lọc...
- Chèn vào đó toàn bộ mã javascript bên dưới đây (Nhớ thay đổi màu tiêu đề truyện (FHeaderColor), màu nội dung (FBodyColor) và cỡ chữ (FFontSize) cho hợp với blog của bạn):
<iframe id="ifrHTMLFunny" name=ifrHTMLFunny frameborder="0" width="98%"></iframe>
<script type="text/javascript">
FHeaderColor = '#336666';
FBodyColor = '#000000';
FFontSize = '12px';
function getRandomPosts(json) {
var maxEntries = 1;
var numPosts = json.feed.openSearch$totalResults.$t;
var indexPosts = new Array();
for (var i = 0; i < numPosts; ++i) {
indexPosts[i] = i;
}
indexPosts.sort(function() {return 0.5 - Math.random()});
var entry = json.feed.entry[indexPosts[0]];
var RandomFunny = document.getElementById('ifrHTMLFunny').contentWindow.document;
RandomFunny.open();
RandomFunny.write('<html><head></head><body><p class="header" style="font-family: Arial, Tahoma, Verdana;color:' + FHeaderColor + ';font-size: '+ FFontSize +';font-weight: bold;">'+ entry.title.$t + '</p><div align="justify" style="font-family: Arial, Tahoma, Verdana;color:' + FBodyColor + ';font-size: '+ FFontSize +';font-weight: normal;">' + entry.content.$t + '</div><p><b>Power by <a href="http://www.cuoititon.com">www.cuoititon.com</a><b></p></body></html>');
RandomFunny.close();
}
</script>
<script src="http://www.cuoititon.com/feeds/posts/default/-/Truy%E1%BB%87n%20c%C6%B0%E1%BB%9Di/?alt=json-in-script&callback=getRandomPosts&max-results=999999" type="text/javascript">
</script>
Mẫu 1:
Đầu tiên, bạn đăng nhập vào Blog, chọn Thiết kế > thêm tiện ích > thêm HTML/Javacript, sau đó dán đoạn code này vào:
<iframe frameborder="1" height="150" src="http://www.luudiachiweb.com/truyencuoi.htm" width="330"></iframe>
Sau đó bạn Lưu lại và thưởng thức nhé!
Bạn có thể thay đổi độ rộng, cao của box, hoặc nếu muốn thêm màu nền cho box thì bạn thêm vào đoạn code màu xanh.
<iframe frameborder="1"style="background:#C6DEFF;"width="330" src="http://www.luudiachiweb.com/truyencuoi.htm" height="150"></iframe>
(Dunghennessy)
Mẫu 2:
- Tạo một widget HTML/JS. Đặt tên theo ý bạn, ví dụ: Truyện cười chọn lọc...
- Chèn vào đó toàn bộ mã javascript bên dưới đây (Nhớ thay đổi màu tiêu đề truyện (FHeaderColor), màu nội dung (FBodyColor) và cỡ chữ (FFontSize) cho hợp với blog của bạn):
<iframe id="ifrHTMLFunny" name=ifrHTMLFunny frameborder="0" width="98%"></iframe>
<script type="text/javascript">
FHeaderColor = '#336666';
FBodyColor = '#000000';
FFontSize = '12px';
function getRandomPosts(json) {
var maxEntries = 1;
var numPosts = json.feed.openSearch$totalResults.$t;
var indexPosts = new Array();
for (var i = 0; i < numPosts; ++i) {
indexPosts[i] = i;
}
indexPosts.sort(function() {return 0.5 - Math.random()});
var entry = json.feed.entry[indexPosts[0]];
var RandomFunny = document.getElementById('ifrHTMLFunny').contentWindow.document;
RandomFunny.open();
RandomFunny.write('<html><head></head><body><p class="header" style="font-family: Arial, Tahoma, Verdana;color:' + FHeaderColor + ';font-size: '+ FFontSize +';font-weight: bold;">'+ entry.title.$t + '</p><div align="justify" style="font-family: Arial, Tahoma, Verdana;color:' + FBodyColor + ';font-size: '+ FFontSize +';font-weight: normal;">' + entry.content.$t + '</div><p><b>Power by <a href="http://www.cuoititon.com">www.cuoititon.com</a><b></p></body></html>');
RandomFunny.close();
}
</script>
<script src="http://www.cuoititon.com/feeds/posts/default/-/Truy%E1%BB%87n%20c%C6%B0%E1%BB%9Di/?alt=json-in-script&callback=getRandomPosts&max-results=999999" type="text/javascript">
</script>
(trích vntim)
Chưa có nhận xét cho: "Gắn hộp thoại truyện cười ngẫu nhiên"
Post a Comment