0

I have a weird problem on my site that only happens in IE9 - I have some js code that I need to add to the page but only for IE9 as it is to sort out the placeholders. However the code is not getting added and I don't know if this is a bug with IE9 or MVC.

The problem is that I put the code for the script at the top of the view - it gets added to a session which then gets rendered on the master template, but in IE9, the view is not being hit so the code doesn't get rendered. I have put a breakpoint onto the view and visited the page in all the browsers. The breakpoint gets hit and then moves onto the master layout in every browser except IE9 where the breakpoint is completely missed (no matter where I put it in the view) and the master layout is loaded first.

However if I do a postback on this page, the view will then be hit and the script will render.

Has anyone had this problem before or know what causes it

Update

the code in the controller isn't hit in IE9 either. Is this a caching problem - if so, how do I stop MVC caching a page

Okay, a further update is in IE9, I have noticed that the url being loaded is http://localhost/Quote/#/Quote/Form/ but in every other browser the url is the correct one: http://localhost/Quote/Form/. If I go to the correct url then the page works properly in IE9.

Is this caused by jQuery mobile ajax enabled option?

4

1 回答 1

0

The error was caused by the # being added to the url. I found that if I entered the following code just before the jQuery mobile script:

 <script type="text/javascript">
    $(document).on("mobileinit", function () {
        $.mobile.ajaxEnabled = @Html.Raw(Request.Browser.IsMobileDevice ? "true" : "false");
    });
</script>

It solved my problem

于 2013-07-31T15:46:03.093 回答