简体   繁体   English

JavaScript在移动设备上不起作用,显示空白

[英]Javascript doesn't work on mobile, shows empty spaces

I have created a reserve schedule which consists of a calendar and certain time. 我创建了一个包含日历和特定时间的储备计划。 On Desktop it works perfectly, also in chrome's emulator, but it doesn't work on mobile, in my case Safari and also Chrome for iOs. 在台式机上,它在chrome的仿真器中也能完美运行,但在移动设备(在我的情况下是Safari和iO的Chrome)中却无法运行。 The calendar days don't show up in mobile. 日历天不会显示在移动设备中。

This is the desktop version. 这是桌面版本。 在此处输入图片说明

This is the mobile version. 这是移动版本。 在此处输入图片说明

The javascript is filled with onclick events and they are all created based on the day, month and year the user is located. javascript充满了onclick事件,它们都是根据用户所在的日期,月份和年份创建的。 I tried removing all onclick events and it showed up fine. 我尝试删除所有onclick事件,但显示正常。 This is how each day of the calendar is created with the function in it. 这就是使用该功能创建日历的每一天的方式。

<div class="calendar__day" id=day'+i+' onclick="changedate('+a+','+i+','+month+','+ finday(i,yyyy,mm) +')"><span class="calendar__date">'+ i +'</span></div>

Is there any workaround to make it workable on mobile also? 是否有任何变通办法使其也可以在移动设备上使用? Is it because of too much javascript or just the onclick function? 是因为JavaScript过多还是仅仅是onclick函数?

After putting console.logs everywhere I found out that the function finday(i,yyyy,mm) which was called with the changedate function on click was being executed everytime a new day was created in the html. 在将console.logs finday(i,yyyy,mm)各处之后,我发现每次在html中创建新的一天时,就会执行通过点击changedate功能调用的finday(i,yyyy,mm)函数。 I don't really know why it happened but I implemented the finday function inside the changedate and it now works. 我真的不知道为什么会发生,但我实现了finday内部功能changedate ,它现在的作品。 I guess it was just too much javascript functions being executed for a mobile browser. 我想这是针对移动浏览器执行的太多javascript函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM