简体   繁体   English

BlogSpot 中的 JavaScript/Jquery 在移动浏览器中不起作用

[英]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,所以我不确定其他人)。

The page is here .页面在 这里

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(&quot;Hello&quot;)</script></b:if>

在此处输入图片说明 在此处输入图片说明

在此处输入图片说明

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

相关问题 jQuery scrollTop()无法在移动浏览器上滚动DIV,替代方案? - jQuery scrollTop() does not work in scrolling DIV on mobile browsers, alternatives? 为什么地理定位不适用于移动浏览器? - Why does geolocation not work on mobile browsers? 为什么地理定位在移动浏览器和桌面上不起作用? - why does geolocation not work on mobile browsers and desktop? 无法在 perticulat blogspot 执行 javascript,但它在其他 blogspot 中工作 - Unable to execute javascript at a perticulat blogspot, but it work in other blogspot 移动浏览器上的Javascript / jQuery页面更改事件 - Javascript / jQuery page change event on mobile browsers javascript / jquery检测移动浏览器的最佳方法? - best method of detecting mobile browsers with javascript/jquery? Javascript / Jquery get()在移动浏览器上不起作用(调用node-red,node.js) - Javascript / Jquery get() won't work on mobile browsers (calling node-red, node.js) jQuery不起作用,但在所有浏览器中都是最后一个元素 - JQuery does not work but last element in all browsers JavaScript内存如何在浏览器中运行? - How does JavaScript memory work in browsers? JavaScript .split函数不适用于所有浏览器 - JavaScript .split function does not work in all browsers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM