SCRIPT5009:“$”在IE9中未定义 [英] SCRIPT5009: "$" is undefined in IE9

查看:429
本文介绍了SCRIPT5009:“$”在IE9中未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个书签,可以将div加载到当前页面并在其中放置iframe。除了IE9之外,bookmarklet在所有浏览器中都像梦一样。甚至适用于IE的早期版本。

I have a bookmarklet that loads a div into a current page and places an iframe inside it. The bookmarklet works like a dream in all browsers except IE9. Even works in earlier versions of IE.

我正在使用以下bookmarklet框架:

I'm using the following bookmarklet framework:

http://idc.anavallasuiza.com/project/bookmarklets

某人其他地方也有类似的问题(与bookmarklet无关):

Some one else has had a similar issue here (not related to bookmarklets):

https://forum.jquery.com/topic/retrieved-html-data-type-with-jquery-ajax-in-ie9-scripts-tags-sources-could-not-be-loaded

到目前为止,我理解我的bookmarklet的jQuery在IE9中没有正确加载。

So far I'm understanding that my bookmarklet's jQuery is not loading properly in IE9.

bookmarklet试图加载自己的jQuery因此,当书签正在初始化时,可以运行某些效果,并且易于编程。

The bookmarklet attempts to load its own jQuery so certain effects can run when the bookmarklet is initialising, and for programming ease.

iFrame页面也加载jQuery(没有它,iframe中的内容无法正常工作) 。

The iFrame page also loads jQuery (without it the content in the iframe does not work properly).

我使用的是最新的jQuery:

I am using the latest jQuery:

http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js

我会想知道为什么IE9在没有其他浏览器的情况下会导致这些SCRIPT错误?为什么jQuery在IE9中没有正确加载?

I would like to know why IE9 causes these SCRIPT errors when no other browser does? Why is jQuery not loading properly in IE9?

任何见解都会非常感激。

Any insight would be much appreciated.

推荐答案

我刚刚花了几个小时来解决这个问题,最后找到了一个我认为可以帮到你的解决方案。

I have just spent some hours wrestling with this problem and finally found a solution that I think will help you.

这是代码的简化版本这给我带来了问题:

Here's a simplified version of the code that caused problems for me:

$frames = $(*html_including_frames_here*);
$div = $('<div></div>');
$div.append($frames);
$('body').append($div);

**将一个或多个帧加载到不在DOM中的div中,然后将该div加载到DOM会导致我的所有问题。这些框架不会按原样加载JS脚本,然后所有内容(jQuery,JSON等)都是未定义的。

** Loading one or more frames into a div that's NOT in the DOM and THEN loading that div into the DOM causes all the problems in my cases. The frames don't load JS scripts as they should, and then everything (jQuery, JSON, etc) are undefined.

另一方面,这可以工作:

This, on the other hand, works:

$frames = $(*html_including_frames_here*);
$div = $('<div></div>');
$('body').append($div);
$div.append($frames);

这里唯一的区别是我将div放在dom中然后将帧加载到它。不知何故,这一切都有所不同。

The only difference here is that I am placing the div in the dom first and THEN loading the frames into it. Somehow that makes all the difference.

这篇关于SCRIPT5009:“$”在IE9中未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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