Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi i have an <iframe> in my page
and now i want wen click on button in iframe it set some style on self !
some style like this : visibility:hidden;position:absolute;display:block
Posted
Updated 29-Nov-14 21:33pm
v2

you can use javascript or jquery to set style on button click event.

These links might be helpful:
http://stackoverflow.com/questions/16086201/jquery-changing-style-of-html-element[^]

http://www.sitepoint.com/change-css-jquery/[^]
 
Share this answer
 
Comments
‫محم د‬‎ 30-Nov-14 4:04am    
NO !!!
I want change iframe property by it self
see this picture : http://upload7.ir/imgs/2014-11/78098470164453134038.jpg
Hi,

I have taken an assumption here that your iFrame displays a webpage which belongs to the same domain because cross-site scripting is not allowed.

I have 2 pages. 1) index.html 2)iframe.html

-------------index.html-----------------
HTML
<html>
	<head>
 	
 </head>
	<body>
		<iframe src="iframe.html" id="iframe1" />
	</body>
</html>


------------iframe.html-------------------
HTML
<html>
	<head>
<script type="text/javascript">
  function hide(){
	var parentWindow = window.top;
	parentWindow.document.getElementById('iframe1').style.display='none';
  }
</script>
 	
 </head>
	<body>
		<input type="button" onclick="hide();" value="Close">
	</input></body>
</html>


Thanks
Srikant
 
Share this answer
 
Comments
‫محم د‬‎ 30-Nov-14 6:07am    
it shuld be work ! but get this Error :
Uncaught SecurityError: Blocked a frame with origin "http://ip:8585" from accessing a frame with origin "http://ip". Protocols, domains, and ports must match.
SrikantSahu 30-Nov-14 8:23am    
That is the constraint with frames. If they load a page from a different domain, they become unaccessible. We no more can access the iframe from our parent page.

However if the iframe belong to the same page as our main/parent page does, we can access the iframe and run the scripts as well.
Can you please check whether both your pages have same domain. Also you can test them by placing them in your same server location.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900