在下面的情況下,我如何才能使$(frame)成爲jQuery對象? 下面是我的鉻開發人員工具的輸出。DOM對象不能成爲jQuery對象
console: mainFrame
output: <frame src="http://someurl.com" name="mainFrame">
console: $(mainFrame).contents()
output: SyntaxError: Failed to execute 'querySelector' on 'Document': '[object HTMLFrameElement]' is not a valid selector.
編輯:
迴應評論...
$.toString()
"function $(selector, [startNode]) { [Command Line API] }"
typeof(mainFrame)
"object"
jQuery
ReferenceError: jQuery is not defined
您能否提供相關的代碼而不是控制檯輸出? –
'$ .toString()'和'typeof mainFrame'的輸出是什麼? – plalx
我認爲問題是這是一個框架標記,如果你不在同一個域,那麼這是一個安全違規。如果你是你可能還需要添加一些如下所示的上下文: $('#myselector',top.frames [「mainFrame」]。document).contents(); –