简体   繁体   English

jQuery干扰javascript搜索功能(传递参数)

[英]jQuery interfering with javascript search function (passing parameters)

I have a pretty basic mobile html site with javascript search to give it offline search functionality. 我有一个非常基本的带有javascript搜索功能的移动html网站,以提供离线搜索功能。 I put in jquery mobile in order to have a fixed toolbar (using phone gap and the ccs fixed position is not supported). 我放入jquery mobile以便具有固定的工具栏(使用电话间隔和不支持ccs固定位置)。 The problem now is that jquery has affected the search functionality by changing the parameters being passed. 现在的问题是,jQuery通过更改传递的参数影响了搜索功能。

You can see the problem when looking at the url. 您可以在查看网址时看到问题。

For example: 例如:

If I search for 'stackoverflow' 如果我搜索“ stackoverflow”

The url should be the following: search.html?searWords=stackoverflow 网址应为以下内容:search.html?searWords = stackoverflow

Below is what is created (note the search box value is 'Search Specs') search.html?searWords=stackoverflow&Send=Search+Specs 以下是创建的内容(请注意,搜索框的值为“搜索规格”)search.html?searWords = stackoverflow&Send = Search + Specs

If I take out the 'Search Specs' from the search button the code just leaves it out, but I get the same result: search.html?searWords=stackoverflow&Send= 如果我从搜索按钮中删除了“搜索规范”,则代码将其省略,但得到的结果相同:search.html?searWords = stackoverflow&Send =

So in a nutshell, the jquery mobile scripts 'jquery-1.6.4.min.js' and 'jquery.mobile.min.js' are inserting &Send=”value of search button” on the end of the url when the search function is used. 因此,简而言之,当使用搜索功能时,jQuery移动脚本'jquery-1.6.4.min.js'和'jquery.mobile.min.js'会在网址末尾插入&Send =“搜索按钮的值”用来。

This is because jQuery mobile uses AJAX navigation by default, meaning it will intercept all links and forms on all your pages and navigate them using URL's like the one you specified (eg page.html#page2.html ). 这是因为jQuery mobile默认使用AJAX导航,这意味着它将拦截所有页面上的所有链接和表单,并使用您指定的URL(例如page.html#page2.html )进行page.html#page2.html This applies to forms as well. 这也适用于表格。

If you can live without this feature, you can turn it off by using ajaxEnabled option. 如果您可以不使用此功能,则可以使用ajaxEnabled选项将其关闭。

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

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