Не получить данные из фрейма
Подскажите почему может не работать конструкция
$("iframe").contents().find("body").html(); Во всех броузерах все ок, а в Опере не пашет. В чем может быть проблема? |
удивительно что вообще работает где-то ибо метод .contents() возвращает не прототип jQuery а чистый элемент
|
тебе надо делать так:
$($("iframe").contents()).find("body").html(); |
Везде где я видел примеры именно в таком формате
$("iframe").contents().find("body").html(); Даже в NetBeans в справке по contents() именно такой формат примера. Но в любом случае, и такой вариант $($("iframe").contents()).find("body").html(); тоже не работает. Опера пишет: Uncaught exception: ReferenceError: Security error: attempted to read protected variable |
вот вырезка кода jQuery-1.6.2 из этого участка:
contents: function( elem ) { return jQuery.nodeName( elem, "iframe" ) ? elem.contentDocument || elem.contentWindow.document : jQuery.makeArray( elem.childNodes ); } |
Цитата:
|
Цитата:
|
Даже на такой код ошибка:
var c = $("iframe").contents(); for(prop in c){ document.write(c[prop]+'<br />') } Вот полностью ошибка Uncaught exception: ReferenceError: Security error: attempted to read protected variable: valueOf Error thrown at line 591, column 4 in <anonymous function>(data) in http://site.net/Scripts/fs.js: document.write(c[prop]+'<br />') called from line 123, column 1033 in b() in http://ajax.googleapis.com/ajax/libs...jquery.min.js: e.success&& called via Function.prototype.call() from line 129, column 367 in <anonymous function: x.onreadystatechange>(q) in http://ajax.googleapis.com/ajax/libs...jquery.min.js: j||b(); |
Что-то у вас много ошибок и в разных местах... этого мало что бы понять проблему, нужно видеть код
|
Ok, буду копать сам. Скорее всего глюки в Опере. Спасибо за помощь
|
Цитата:
softrix, Вы уверены, что текущий домен и домен во фрейме полностью совпадают, вплоть до www. Цитата:
|
Цитата:
|
Цитата:
*!* jQuery.each({ */!* // другие методы // … contents: function( elem ) { return jQuery.nodeName( elem, "iframe" ) ? elem.contentDocument || elem.contentWindow.document : jQuery.makeArray( elem.childNodes ); } *!* }, function( name, fn ) { jQuery.fn[ name ] = function( until, selector ) { var ret = jQuery.map( this, fn, until ), // The variable 'args' was introduced in // [url]https://github.com/jquery/jquery/commit/52a0238[/url] // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. // [url]http://code.google.com/p/v8/issues/detail?id=1050[/url] args = slice.call(arguments); if ( !runtil.test( name ) ) { selector = until; } if ( selector && typeof selector === "string" ) { ret = jQuery.filter( selector, ret ); } ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { ret = ret.reverse(); } return this.pushStack( ret, name, args.join(",") ); }; }); */!* |
Цитата:
|
Часовой пояс GMT +3, время: 14:59. |