Jump to content

iframe


pankaj.ghadge

Recommended Posts

Is it possible to call iframe function by using iframe object.......when we use the window.open function it returns the window object. from that window object it is possible to call the javascript function written in newly open window (pop-up window).so same like window object it is possible to call javascript function using iframe object.............please tell me..........I have created a user class and different object of that class will call the method written in iframe.e.g iframeObj1.demoFun(); //user1 is object of user class iframeObj2.demoFun(); //user2 is object of user class iframeObj3.demoFun(); //user3 is object of user classfor window object windowObj=window.open("demo.html", "width=320,height=390,resizable=yes");windowObj.functionDemo(); this will call the javscript method written in demo.htmlconsider i have included same iframe three time in my HTML page. so is this possible .........

Link to comment
Share on other sites

Yes, this is possible, but it's a bit tricky. The page in the iframe has to want you to access it. I've never investigated the effects of this on the same-domain policy.

<html>	<head>		<script type="text/javascript">			function doSomethingWith(doc){				//...			}		</script>	</head>	<body>		<iframe src="iframe.html" id="iframe">Your browser doesn't support iframes.</iframe>	</body></html>

iframe.html

<html>	<body>		// page here, then the script - same as using window.onload		<script type="text/javascript">			if(parent !== window && typeof parent.doSomethingWith == 'function'){				parent.doSomethingWith(document);			}		</script>	</body></html>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...