

<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>风名博客</title><link>https://windname.com/</link><description>风名博客网</description><item><title>jquery之jqtouch/谷歌地图 API v3 问题</title><link>https://windname.com/post/aejgei2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我很难将 jQtouch 和 Google Maps api V3 结合在一起。我几乎尝试了一切。看来唯一的信息来源是&lt;a href=&quot;http://code.google.com/p/jqtouch/issues/detail?id=44&quot; rel=&quot;noreferrer noopener nofollow&quot;&gt;here&lt;/a&gt;我检查了每一个帖子。我从 jQuery 和 css 开始...所以有很多东西我不明白。&lt;/p&gt; 
   &lt;p&gt;首先，我使用 jQtouch 框架构建一个与谷歌地图集成的网络应用程序，问题是每当我平移 map 时，都会发生奇怪的闪烁。就好像jQtouch和 map 在努力争取回调一样。 &lt;/p&gt; 
   &lt;p&gt;我正在使用最新版本。并且存在一些关于过渡/动画功能的错误(因为我没有将 map 和所有元素的 div 包装在 #jqt 包装器中)以及某些样式的 css 问题。有人已经成功实现了此场景的功能设置构建吗？ (谷歌地图API v3和jqtouch)，我认为没有必要向您粘贴一些代码(但如果您认为有必要，请告诉我，我会这样做)，如果您向我粘贴一个带有 map 的最小示例(详细说明jqtouch版本，以及对styles/.js文件的修改)，以及一些从 map 到另一个div/section/page的来回转换，你摇滚。&lt;/p&gt; 
   &lt;p&gt;提前非常感谢。&lt;/p&gt; 
   &lt;p&gt;请告诉我这是否“合法”，我的意思是，官方 wiki 上有太多松散的信息，比如 13 个“解决方案”，但没有什么具体的...我只是想帮助将来遇到这个问题的任何人。&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我没有在 iPhone 上使用 GMap 的经验，但我确实注意到，当通过 &lt;code&gt;position:absolute&lt;/code&gt; 平移事物时，jQTouch 似乎会奇怪地闪烁，这可能是平移事物的最常见方式 - jQTouch 不知何故更喜欢使用 &lt;code&gt;margin&lt;/code&gt; 进行平移。我真的不确定这是否有任何帮助(因为我不确定您是否可以在 GMap 中更改此设置)。&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item><item><title>jQuery Ajax : Copy之Paste thingy</title><link>https://windname.com/post/aejgeh2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我有一个表单，其中检查输入字段的值，然后使用 typewatch 插件(一个小东西，检测用户在预定义的时间间隔后停止输入)进行 Ajax 调用。效果很好。&lt;/p&gt; 
   &lt;p&gt;由于此字段是订单中的“优惠券折扣”，因此可以通过复制粘贴电子邮件或其他内容中的“优惠券代码”来输入该值。它还可以与 Ctrl+C - Ctrl+V 一起使用来进行复制和粘贴，但当用户使用鼠标选择文本、从上下文菜单中单击复制，然后从此菜单中粘贴时，则不能使用。&lt;/p&gt; 
   &lt;p&gt;jQuery 中有没有办法以某种方式检查 jQuery 中的这种行为？&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;您可以设置一个较短的超时(1 秒)来检查自上次检查以来值是否已更改。&lt;/p&gt; 
   &lt;p&gt;您也可以简单地忽略它，当表单提交时，获取此优惠券折扣输入的内容并进行处理。&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item><item><title>jquery之试图隐藏选择列表中的选项..不适用于 chrome 和 ie</title><link>https://windname.com/post/aejgeg2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我有一个选择列表，其中有很多选项。根据某些输入，我想从选择列表中隐藏一些选项。为了隐藏选择列表中的选项，我编写了像 &lt;/p&gt; 这样的 jquery 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$('#selectlist1 option').each(function(){   
 
   $(this).hide(); 
 
}) 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;但是这段代码似乎只适用于 Firefox，不适用于 chrome 和 ie。而如果我写 &lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$('#selectlist1').hide(); 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;它适用于所有浏览器。有什么指针我应该看哪里吗？&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;这是一种相对简洁的方法，可以根据需要使用新选项重建选择列表。这适用于动态插入的选项(这是 IE 和 Chrome 的显示和隐藏问题)&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$().ready(function() { 
    //store a reference 
    var select = $('#myselect'); 
}); 
 
function rebuild_select(arr_new_options) { 
    var parent = select.parent(); 
    select.empty(); 
    var clone = select.clone(); 
    select.remove(); 
    for(var x=0; x &amp;lt; arr_new_options.length; x++) { 
        clone.append(arr_new_options[x]); 
    } 
    parent.append(clone); 
    select = clone; 
} 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item><item><title>asp.net之当鼠标悬停在元素上加载页面时，jQuery 触发 mouseover 函数</title><link>https://windname.com/post/aejgef2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我有一个 ASP.NET 文档，其中包含一个 Image 元素。&lt;br&gt; 我在此图像元素上创建了一个 &lt;code&gt;mouseover&lt;/code&gt; 函数，它工作正常。&lt;br&gt; 问题是:&lt;br&gt; 如果文档加载自身时鼠标已经位于元素上，则 &lt;code&gt;mouseover&lt;/code&gt; 函数不会触发(我需要 &lt;code&gt;mouseout&lt;/code&gt; 然后 &lt;code&gt;mouseover&lt;/code&gt;再次以触发它)。&lt;br&gt; 如果鼠标已经位于该元素的顶部，有什么方法可以检查 &lt;code&gt;$(document).ready&lt;/code&gt; 函数吗？如果是，则触发 &lt;code&gt;mouseover&lt;/code&gt; 功能。&lt;br&gt; 谢谢大家!&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;为什么不使用&lt;code&gt;mousemove&lt;/code&gt;事件？您可以通过将名为 movingOver 的标志设置为 true，然后在 &lt;code&gt;mouseleave&lt;/code&gt;&lt;/p&gt; 上将该标志设置为 false，使其仅触发一次 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item><item><title>jquery之使用 jQuery 将当前 URL 与 UL 中的 herf 进行匹配，如果匹配则添加类</title><link>https://windname.com/post/aejgee2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我有一个动态创建的 UL。我想使用 jQuery 使用当前 URL，搜索指定的 UL 并找到任何具有匹配 href 的 li。如果找到，则添加“current_page”类。&lt;/p&gt; 
   &lt;p&gt;我想出了这个，但似乎没有效果。&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$(document).ready(function() {   
    $(&quot;ul.nav_cat_archiveli&quot;).find(&quot;a[href='&quot;+window.location.pathname+&quot;']&quot;).each(function() { 
        $(this).addClass(&quot;current_page&quot;); 
    }); 
}); 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;你可以玩&lt;a href=&quot;http://www.w3schools.com/jsref/obj_location.asp&quot; rel=&quot;noreferrer noopener nofollow&quot;&gt;window.location&lt;/a&gt;这将返回当前页面 URL 以及 &lt;a href=&quot;http://www.w3schools.com/jsref/prop_loc_href.asp&quot; rel=&quot;noreferrer noopener nofollow&quot;&gt;href&lt;/a&gt; window.location 的属性&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item><item><title>Chrome 中的 JQuery 问题</title><link>https://windname.com/post/aejged2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我有一个使用 JQuery 进行 ajax 调用的页面。在 Chrome 中查看该页面会在开发者控制台中显示以下错误:&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt; Uncaught TypeError: Cannot set property 'display' of undefined 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;虽然同一页面在 Firefox 3.6.6 中运行，但 Firebug 控制台中没有任何错误。&lt;/p&gt; 
   &lt;p&gt;错误源自 j-query-1.4.2 中的一行(如 chrome 控制台所示)&lt;/p&gt; 
   &lt;p&gt;还有其他人面临类似问题吗？&lt;/p&gt; 
   &lt;p&gt;基本上，我使用的是显示在模态对话中的 DatePicker。&lt;/p&gt; 
   &lt;p&gt;这是代码:&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$(document).ready(function () { 
$(&quot;#inputs input[name=dateField]&quot;).datepicker( 
        { 
            showOn: 'both', 
            dateFormat:'dd/mm/yy HH:II TT', 
            showButtonPanel: true,  
            maxDate: '+0D', 
            buttonImage:'calendar.gif', 
            buttonImageOnly: true, 
        } 
); 
 }); 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我建议您开始在 Chrome 的开发者控制台中尝试您的代码行。在页面上打开开发人员工具(以便加载所有代码)并转到控制台选项卡。输入/粘贴到控制台:&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$(&quot;#inputs input[name=dateField]&quot;) 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;看看是否返回一个具有长度的对象。如果返回的对象只有“context”、“selector”和“__ proto__”属性，jquery 找不到任何内容。如果它还有一个“长度”属性，以及名为数字的属性(“0”、“1”等)，那么它会找到某个东西(或多个东西)。 &lt;/p&gt; 
   &lt;p&gt;从那里，您可以尝试其他代码，看看 Chrome 会说什么。&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item><item><title>jQuery ajax 错误处理 &quot;script&quot;dataType</title><link>https://windname.com/post/aejgec2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我正在使用 jQuery 的 AJAX 函数的包装函数，如下所示:&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$.getAjax = function(url, type, callback){ 
    $.ajax({ 
        url: url, 
        cache: false, 
        dataType: type, 
 
        success: function(){ 
            alert(&quot;success&quot;); 
        }, 
        complete: function(XMLHttpRequest, textStatus){ 
            alert(&quot;complete&quot;); 
 
            if (callback != undefined) { 
                callback(); 
            } 
        }, 
        error: function (XMLHttpRequest, textStatus, errorThrown){ 
            alert(&quot;error&quot;); 
        } 
    }); 
} 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;当我使用“text”作为数据类型时，即使 url 无效，它也能完美工作。当 url 无效时，它首先调用错误，然后调用完整函数。没关系。 但是，当我使用“script”作为数据类型时，当 url 无效时它不会调用任何内容。 当我使用“script”作为数据类型时，我应该如何捕获 HTTP 404 错误和其他错误？ &lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我查看了 jQuery 的源代码，发现它没有调用任何错误处理程序方法。事实上，只有当http get请求成功时，它才会调用success()和complete()函数。&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;// If we're requesting a remote document 
        // and trying to load JSON or Script with a GET 
        if ( s.dataType === &quot;script&quot; &amp;amp;&amp;amp; type === &quot;GET&quot; &amp;amp;&amp;amp; remote ) { 
            var head = document.getElementsByTagName(&quot;head&quot;)[0] || document.documentElement; 
            var script = document.createElement(&quot;script&quot;); 
            script.src = s.url; 
            if ( s.scriptCharset ) { 
                script.charset = s.scriptCharset; 
            } 
 
            // Handle Script loading 
            if ( !jsonp ) { 
                var done = false; 
 
                // Attach handlers for all browsers 
                script.onload = script.onreadystatechange = function() { 
                    if ( !done &amp;amp;&amp;amp; (!this.readyState || 
                            this.readyState === &quot;loaded&quot; || this.readyState === &quot;complete&quot;) ) { 
                        done = true; 
                        success(); 
                        complete(); 
 
                        // Handle memory leak in IE 
                        script.onload = script.onreadystatechange = null; 
                        if ( head &amp;amp;&amp;amp; script.parentNode ) { 
                            head.removeChild( script ); 
                        } 
                    } 
                }; 
            } 
 
            // Use insertBefore instead of appendChild  to circumvent an IE6 bug. 
            // This arises when a base node is used (#2709 and #4378). 
            head.insertBefore( script, head.firstChild ); 
 
            // We handle everything using the script element injection 
            return undefined; 
        } 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item><item><title>jQuery:如何包装()动态加载的元素</title><link>https://windname.com/post/aejgeb2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我正在为一个本身没有 HTML 的第 3 方应用程序换肤。这一切都来自 onLoad 事件和一堆 ajax 调用。&lt;/p&gt; 
   &lt;p&gt;我将 jQuery 添加到页面中。我需要wrapp()一个动态加载的元素。如果需要，我可以添加一个插件。&lt;/p&gt; 
   &lt;p&gt;我该怎么做？谢谢。&lt;/p&gt; 
   &lt;p&gt;更新: 这可行，但是有更好的方法吗？&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$(document).ready(function() { 
 
(function() { 
  var length = $(&quot;.applicationShell&quot;).length; 
 
  var h = setInterval(function () { 
    if ($(&quot;.applicationShell&quot;).length &amp;gt; length) { 
      length = $(&quot;.applicationShell&quot;).length; 
      clearInterval(h); 
 
 
      $(&quot;.applicationShell&quot;).addClass(&quot;test&quot;) 
 
    } 
  }, 100); 
})(); 
 
 
}); 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;嗯，看来我找不到更好的解决方案了。 :( 这是我用过的。&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$(document).ready(function() { 
 
(function() { 
  var length = $(&quot;.applicationShell&quot;).length; 
 
  var h = setInterval(function () { 
    if ($(&quot;.applicationShell&quot;).length &amp;gt; length) { 
      length = $(&quot;.applicationShell&quot;).length; 
      clearInterval(h); 
 
 
      $(&quot;.applicationShell&quot;).addClass(&quot;test&quot;) 
 
    } 
  }, 100); 
})(); 
 
 
}); 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item><item><title>jQuery 晚于窗口加载</title><link>https://windname.com/post/aejgea2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我正在使用 &lt;code&gt;Cufon.replace&lt;/code&gt; 来字体替换网站上的一些文本。目前在 IE8 标准模式下，当它在 $(document).ready 之外运行时，它只会发生大约 50% 的时间，其余时间发生 DOM 更改(使用 IE8 内置的开发工具栏查看)，但没有文本显示。&lt;/p&gt; 
   &lt;p&gt;禁用替换并通过控制台手动应用它会正确更新所有文本。 将其包装在 &lt;code&gt;$(document).ready&lt;/code&gt; 中可以阻止它发生 - 没有 DOM 修改(据我从开发工具栏可以看出)。但是我无法从控制台手动重新申请 - 所以它可能在骗我。&lt;/p&gt; 
   &lt;p&gt;将其包装在 &lt;code&gt;$(window).load&lt;/code&gt; 中似乎与 &lt;code&gt;$(document).ready&lt;/code&gt; 具有相同的效果&lt;/p&gt; 
   &lt;p&gt;请注意，这仅影响 ie8“标准模式”。它在 Firefox 和 IE7 中运行良好。&lt;/p&gt; 
   &lt;p&gt;有什么想法吗？&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我以前经历过这种情况...我会将其包装在匿名函数中，您也可以使用简单的 setTimeout 来延迟它(可能不需要)。&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;(function( $ ){  
   // Your Cufon.replace() 
   Cufon.replace('h1', { fontFamily: 'stack-overflow', hover: true }); 
   Cufon.now(); 
 
   // OPTIONAL - Delay by 150ms (you can experiment with this value) 
   setTimeout(function(){ Cufon.refresh(); }, 150);  
 
})( jQuery ); 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item><item><title>jquery之通过文件://triggers cross-domain null origin violation,加载本地JSON文件解决方案 (jQuery)</title><link>https://windname.com/post/aejgej2b1.html</link><description>&lt;html&gt;
 &lt;head&gt;&lt;/head&gt;
 &lt;body&gt;
  &lt;div id=&quot;question&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;我想在本地使用一个网页，无需网络服务器，只需在浏览器中打开本地 HTML 文件即可。该网页通过 jQuery 的 getJson() 方法加载数据，如下所示:&lt;/p&gt; 
   &lt;pre class=&quot;prism-language-java&quot;&gt;&lt;code&gt;$.getJSON(&quot;mydata.json&quot;, function(j) {  
... 
&lt;/code&gt;&lt;/pre&gt; 
   &lt;p&gt;JSON 文件也是本地的，并且存储在与网页相同的目录中。当我尝试使用该页面时，我得到:&lt;/p&gt; 
   &lt;p&gt;&lt;strong&gt;Access-Control-Allow-Origin 不允许 Origin null。&lt;/strong&gt;&lt;/p&gt; 
   &lt;p&gt;(Chrome 6 OS X，Firefox 和 Safari 中出现类似错误)。&lt;/p&gt; 
   &lt;p&gt;有什么办法可以解决这个问题吗？是否可以从本地文件加载 JSON？谢谢!&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px;&quot;&gt; 
   &lt;p&gt; &lt;strong&gt;&lt;font size=&quot;5&quot;&gt;请您参考如下方法:&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div id=&quot;answer&quot;&gt; 
   &lt;p&gt;&lt;/p&gt; 
   &lt;p&gt;尝试使用 &lt;code&gt;--allow-file-access-from-files&lt;/code&gt; 运行 Chrome。&lt;/p&gt; 
   &lt;p&gt;&lt;/p&gt; 
  &lt;/div&gt; 
  &lt;div style=&quot;margin-top: 20px; margin-bottom: 40px;&quot;&gt;  
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;&lt;br&gt;</description><pubDate>Fri, 31 Jul 2026 16:07:35 +0800</pubDate></item></channel></rss><!--31.38 ms , 6 query , 1642kb memory , 4 error-->