什么会导致 FF 和 Chrome 回发两次(一次完全重新加载)?

发布于 2024-12-10 14:57:33 字数 1455 浏览 1 评论 0原文

我正在寻找想法,但不知道从哪里开始。

当我在 FF 和 Chrome 中单击按钮时,我的页面会执行回发并遵守 if(!ispostback),但紧接着,它会执行另一个操作,但这一次就像整个页面重新加载一样,它会运行我的 if(!ispostback) 的内容。 ispostback)

我的网页有 6 个面板,它们的作用有点像向导,每次单击“下一个”时,一个面板就会变得不可见,而另一个面板则可见。(这样做的原因是因为我需要验证一个面板中的所有信息)去,但无法显示一次全部完成,因为有很多!)

第一个面板包含一个在 window.onload 上设置的谷歌地图,如下所示:(尽管这可能与问题完全无关)

 window.onload = function () {
    initialize();
}
var map;
function initialize() {
    var latlng;
    if ('<%=Latlng %>' != '' ) {
        latlng = new google.maps.LatLng(<%=Latlng %>);
    }       
    else {
        latlng = new google.maps.LatLng(54.290882, -4.833984);
    }
    var myOptions = {
        zoom: 4,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var mapCanvas=document.getElementById("map_canvas");
    if(mapCanvas !=null){ 
    map = new google.maps.Map(mapCanvas, myOptions);

  if ('<%=Latlng %>' != '') {     
    var marker = new google.maps.Marker({
            map: map,
            position: latlng
        });
        map.setZoom(12);}
        else if(document.getElementById('<%=txtPostCode.ClientID %>').value != '')
    {
    SetMap(document.getElementById('<%=txtPostCode.ClientID %>'));
    }  
    }
}

其余的只是文本框和转发器。

我读过的唯一可能导致问题的内容是 img 控件上的空“src”属性。所以我尝试删除所有的 img 控件,但没有什么区别。

我在此页面中有很多信息,因此无法全部粘贴,但由于缺少遍历所有内容并逐一删除以找到有问题的对象,有人知道从哪里开始吗?

它在 IE 中不这样做!?

贝克斯

I am looking for ideas I don't know where to start with this one.

When I click a button in both FF and Chrome my page does a postback and obeys the if(!ispostback), but immediately after, it does another but this time it's like a full page reload and it runs the contents of my if(!ispostback)

My webpage has 6 panels that are acting kind of like a wizard, every time you click next one panel is made invisible, and one visible.(The reason it is done this way is because I need to validate al the info in one go, but cannot show it all at once as there is a lot of it!)

The first panel contains a google map that is set up on the window.onload as so: (although this may be completely irrelevant to the problem)

 window.onload = function () {
    initialize();
}
var map;
function initialize() {
    var latlng;
    if ('<%=Latlng %>' != '' ) {
        latlng = new google.maps.LatLng(<%=Latlng %>);
    }       
    else {
        latlng = new google.maps.LatLng(54.290882, -4.833984);
    }
    var myOptions = {
        zoom: 4,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var mapCanvas=document.getElementById("map_canvas");
    if(mapCanvas !=null){ 
    map = new google.maps.Map(mapCanvas, myOptions);

  if ('<%=Latlng %>' != '') {     
    var marker = new google.maps.Marker({
            map: map,
            position: latlng
        });
        map.setZoom(12);}
        else if(document.getElementById('<%=txtPostCode.ClientID %>').value != '')
    {
    SetMap(document.getElementById('<%=txtPostCode.ClientID %>'));
    }  
    }
}

The rest are just textboxes and repeater.

The only thing I have read that may cause the problem is empty "src" attributes on img controls. So I have tried deleting all my img controls and it makes no difference.

I have alot of info in this page so cannot paste it all, but short of going through everything and removing bits one by one to find the offending object, does anyone have any ideas where to start?

It doesn't do it in IE!?

Bex

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

治碍 2024-12-17 14:57:33

不过,我猜“空 src 属性”现象是问题的根源。对于某些类别的空属性,FF 会愉快地将它们解释为对当前 URL 本身的引用,并触发页面的第二次 GET,试图将返回的数据用作某种内容。这将是您在页面生命周期中看到的非回发运行。网络分析工具还应该显示附加请求。

您可以尝试浏览呈现的 HTML(即查看浏览器中的页面源代码)并搜索可能导致该行为的 "" 属性。

I'd guess the "empty src attribute" phenomenon is at the root of your problem, though. For some categories of empty attributes, FF will gleefully interpret these as references to the current URL itself and trigger a second GET of your page, in an attempt to use the returned data as some kind of content. This would be the non-PostBack run through the page lifecycle you're seeing there. Network profiling tools should also show that additional request.

You could try going through the rendered HTML (i.e., look at the page source in your browser) and search for "" attributes that might cause that behavior.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文