jQuery Mobile URL添加#标记,这会破坏Internet Explorer中的表单 [英] jquery Mobile urls add # tag which breaks forms in Internet Explorer

查看:104
本文介绍了jQuery Mobile URL添加#标记,这会破坏Internet Explorer中的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我的问题是我有一个jquery移动网站,其链接类似于普通的

Hi guys my problem is that I have a jquery mobile site with links like normal e.g

<a href="http://mysite.com/login">Login</a> 

现在,当他们在firefox等中转到该页面时,它将转到

Now when they go to that page in firefox etc it goes to

http://mysite.com/#login

然后浏览器启动并删除#,以便转到

Then the browser kicks in and removes the # so it goes to

http://mysite.com/login

问题在于,在Internet Explorer中不会发生这种情况,并且会显示(在这种情况下)登录表单,但是帖子并不想工作,只能返回首页,所以

The problem is that in Internet Explorer this doesn't happen and that it displays (in this case) the login form but the post doesn't want to work and just goes back to the homepage so

http://mysite.com

我听说有人说要删除Ajax以解决此问题,但这不是不能解决真正的问题吗?

I've heard people saying to remove the ajax to fix this but isn't this not fixing the real problem?

任何帮助都会很棒.

如果我删除#则魔术就可以了.就是这样.

If I remove the # then magic it all works. Just so you know.

谢谢 理查德

我正在使用jquery mobile,因此将它们包含在标题中.

I'm using jquery mobile so I'm including these in my header.

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
        <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>

推荐答案

只需在您的layout(master)中添加以下jquery代码,您的网站就可以在IE.It中正常工作了. 此代码获取表单标签.如果您的视图没有表单标签,请添加表单标签.并看到奇迹.

just add below jquery code in your layout(master) and you will get your site working in IE.its really working .... This code get form tag. If your view doesn't have form tag then include form tag. and See miracle.

 <script type="text/javascript">
           $(document).ready(function () {
           if ($.browser.msie || $.browser.webkit) {

               $("a").attr("data-ajax", "false");
               $("a").attr("rel", "external");

               var a = $("form");
               if (a != null) {
                   $("form").first().attr("data-ajax", "false");
                   $("form").first().attr("rel", "external");
               }
           }
       });
   </script>

这篇关于jQuery Mobile URL添加#标记,这会破坏Internet Explorer中的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆