G'全天,
我希望你能帮助我解决为什么我的函数()会在我的" Blogger"发布,仅适用于台式机和平板电脑,但不适用于手机?
我已将以下代码放入我的博客"模板,我把它称为帖子,如下所示。它适用于台式机和Ipads显示器,但不适用于手机显示器。
如果我删除了function()命令并将代码直接插入到帖子中,那么它适用于所有设备,因此我不明白为什么它不能在具有该功能的移动设备上工作。
<!--MyAds Start-->
<script language="JavaScript">
<!-- Begin
var total_banner = 3;
var actual_time = new Date()
var second = actual_time.getSeconds()
var show_the_banner = second % total_banner;
show_the_banner +=1;
if (show_the_banner==1) {
txt="Comprehensive Babies, Parent - Teacher <br /> Swimming Lesson Plan";
url="http://www.swimteaching.com/2015/05/comprehensive-babies-parent-teacher.html";
alt="Image of a baby swimming";
banner="http://1.bp.blogspot.com/-kH9zGxIMnxw/VTsVL8jwkwI/AAAAAAAABBI/a1sx-GrBsSE/s320/baby_child_swim.jpg";
width="250";
height="190";
}
if (show_the_banner==2) {
txt="Get Your Free<br />Swim Lesson Plans Here";
url="http://swimteaching.yolasite.com/lesson-plans-actual.php";
alt="Image of swim teacher helping a child float";
banner="http://2.bp.blogspot.com/-GA8EJHSPug4/SOQFcHZ6oSI/AAAAAAAAAK0/eX7vsIalmfc/s320/FloatBackTeacherHead.jpg";
width="200";
height="100";
}
if (show_the_banner==3) {
txt="Get Your<br />Professional Swimming Lesson Plans<br />Here";
url="http://www.swimteaching.com/2015/04/professional-swiming-lesson- plans.html";
alt="Image of swim teach teaching";
banner="http://4.bp.blogspot.com/-2dpWzVuQqGg/Ux6h5Q2Ti_I/AAAAAAAAAvk/EjHf05GcRXc/s320/How%2Bto%2BFind%2Bthe%2BRight%2BSwim%2BTeacher%2Bfor%2BYour%2BChild%2527s%2BNeeds.JPG";
width="250";
height="100";
}
function myads(){
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_top\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<large><strong>' + txt + '</strong></large></a>');
document.write('</center>');
}
// End -->
</script>
<!--MyAds End-->
以下代码插入帖子
<!--MyAds Start-->
<script language="JavaScript">
myads();
</script>
<!--MyAds End-->
感谢您的帮助 理查德
答案 0 :(得分:0)
function square(arr) {
var sqrt = Math.sqrt(arr.length); // square root of arr.length
var n = Math.ceil(sqrt); // number of sub-arrays (ceil)
var cols = Math.floor(sqrt); // number of items in each sub-array (floor)
var result = []; // the result array
for(var i = 0; i < n; i++)
result.push(arr.slice(i * cols, (i + 1) * cols)); // get the sub-array from array (cut cols elements from arr starting from the index i * cols)
return result;
}