Jquery 是否有标准方法定义在document.open调用中打开的href?

Jquery 是否有标准方法定义在document.open调用中打开的href?,jquery,internet-explorer-7,internet-explorer-6,jquery-bbq,Jquery,Internet Explorer 7,Internet Explorer 6,Jquery Bbq,我要处理的难题是,在中,由于IE6和IE7不支持hashchange,因此它们加载页面两次以获得历史状态 这会产生负面影响,因为代码在服务器端和客户端上都运行了两次。用于创建iframe的方法如下: if ( is_old_ie ) { // Create hidden IFRAME at the end of the body. iframe = $('<iframe src="javascript:0"/>').hide().appendTo( 'body'

我要处理的难题是,在中,由于IE6和IE7不支持
hashchange
,因此它们加载页面两次以获得历史状态

这会产生负面影响,因为代码在服务器端和客户端上都运行了两次。用于创建iframe的方法如下:

  if ( is_old_ie ) {

    // Create hidden IFRAME at the end of the body.
    iframe = $('<iframe src="javascript:0"/>').hide().appendTo( 'body' )[0].contentWindow;

    // Get history by looking at the hidden IFRAME's location.hash.
    get_history = function() {
      return get_fragment( iframe.document.location.href );
    };

    // Set a new history item by opening and then closing the IFRAME
    // document, *then* setting its location.hash.
    set_history = function( hash, history_hash ) {
      if ( hash !== history_hash ) {
        var doc = iframe.document;
        doc.open().close();
        doc.location.hash = '#' + hash;
      }
    };

    // Set initial history.
    set_history( get_fragment() );
  }
关于“是否有定义在document.open调用中打开的href的标准方法?”


不,没有。

如果我给您一种用jquery处理hashchange事件的替代方法,它可以解决您的问题吗?如果您可以解决hashchange加载两次的问题,它将为您节省大量时间。jQuery BBQ文档提到:“请确保绑定到document.ready上的“hashchange”事件,而不是之前,否则它可能会在IE6/7中失败。”这不是您的问题,是吗?此外,您还可以将您的问题发布到位于的project GitHub页面
$('<iframe src="/iframe-loading.php"/>').hide().appendTo('body');
document.open().close()
 $( document.defaultView ).load(function() {
    $('<iframe src="iframe-doneloading.php/>').hide().appendTo('body');
});