[英]JavaScript/Jquery in BlogSpot does not work in mobile browsers
My page in BlogSpot works fine except in the mobile browsers I've tried (only an old iPod touch and my Windows 8 Phone, so I'm not sure about others).我在 BlogSpot 中的页面工作正常,除了我尝试过的移动浏览器(只有旧的 iPod touch 和我的 Windows 8 Phone,所以我不确定其他人)。
Basically, after pressing a button object, JQuery populates a DIV with an .html() function, making the DIV grow in size, and I think that's the problem.基本上,在按下按钮对象后,JQuery 使用 .html() 函数填充 DIV,使 DIV 的大小增加,我认为这就是问题所在。
I was wondering if there is any way to fix this.我想知道是否有任何方法可以解决这个问题。
The problem here is that blogger loads different templates for mobile device and a PC.这里的问题是博主为移动设备和 PC 加载了不同的模板。 The PC version of your blog has all the necessary codes to run the function but the mobile template don't seem to have them.
您博客的 PC 版本具有运行该功能所需的所有代码,但移动模板似乎没有这些代码。
Your script and the jQuery library doesn't load up in the mobile template, so you need to make some changes in your template to make it load on mobile browsers too.您的脚本和 jQuery 库不会加载到移动模板中,因此您需要对模板进行一些更改以使其也加载到移动浏览器上。 It's very simple, all you have to do is wrap the codes between
很简单,你所要做的就是将代码包裹起来
<b:if cond='data:blog.isMobile'></b:if>
And the scripts will be loaded in mobile templates too.脚本也将加载到移动模板中。
It must look like this它必须看起来像这样
<b:if cond='data:blog.isMobile'>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
// your script
</script>
</b:if>
Place this anywhere template (best if near the original scripts) and save the template.将此模板放置在任何地方(最好靠近原始脚本)并保存模板。 And first check it on your PC by loading the mobile template of your blog, to do that just add
?m=1
at the end of your blog's URL.首先通过加载您博客的移动模板在您的 PC 上检查它,只需在博客 URL 的末尾添加
?m=1
。
As @Deepak Kamat stated .. it won't work even if you put the javascript code inside正如@Deepak Kamat 所说.. 即使你把 javascript 代码放在里面也不会工作
<b:if cond='data:blog.isMobile'></b:if>
All you need to do is choose the right mobile template, in this case I believe you've made some changes on your Desktop template, so you must choose "Custom" from the mobile template drop down list您需要做的就是选择正确的移动模板,在这种情况下,我相信您对桌面模板进行了一些更改,因此您必须从移动模板下拉列表中选择“自定义”
Yes, i tried to fix this then i found some steps to enable this on mobile mode but when you put this script code in add gadget then for me it not worked here is some step that i followed - first i opened the theme and then click on ... menu choose edit html and finally put these below line of code and it worked.是的,我试图解决这个问题然后我找到了一些步骤来在移动模式下启用它但是当你把这个脚本代码放在添加小工具然后对我来说它不起作用这是我遵循的一些步骤 - 首先我打开主题然后单击在 ... 菜单上选择编辑 html,最后将这些放在代码行下方,并且它起作用了。 i posted some of picture hope it will be helped.
我贴了一些图片希望它会有所帮助。
<b:if cond='data:blog.isMobile'><script>console.log("Hello")</script></b:if>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.