Programming/Web

[Javascript] Iframe document 얻기.

Fimtrus 2014. 8. 13. 15:09

query에는 css 선택자를 넣어주면된다

ex) getFrameDocuement("#frame1");


function getFrameDocument( query ) {
	var frame = document.querySelector( query );
	if (frame == null)
		return;

	var frameDocument = frame.contentWindow || frame.contentDocument;
	return frameDocument;
}