如何从自我设置样式到iframe! ? [英] How I Can Set Style To Iframe From Self ! ?

查看:75
本文介绍了如何从自我设置样式到iframe! ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我有< iframe>在我的页面

现在我想要点击iframe中的按钮它在自己设置一些风格!

这样的样式:visibility:hidden; position:absolute; display:block

解决方案

你可以使用javascript或jquery来设置样式按钮点击事件。



这些链接可能会有所帮助:

http://stackoverflow.com/questions/16086201/jquery-changing-style-of-html-element [ ^ ]



http://www.sitepoint.com/change-css-jquery/ [ ^ ]






我在这里假设您的iFrame显示属于同一域的网页,因为不允许跨站点脚本ed。



我有2页。 1)index.html 2)iframe.html



------------- index.html -------- ---------

 <   html  >  
< head >

< / head >
< < span class =code-leadattribute> body >
< iframe src = iframe.html id = iframe1 / >
< / body >
< / html >





------------ iframe。 html -------------------

 <   html  >  
< head >
< script type = text / javascript >
function hide(){
var parentWindow = window .top;
parentWindow。 document .getElementById(' iframe1 ')。style.display = ' none';
}
< / 脚本 >

< / head >
< 正文 >
< input type = 按钮 onclick = hide(); value = 关闭 <跨越ss =code-keyword>>
< / input > < / body >
< / html >





谢谢

Srikant


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

解决方案

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/[^]


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>
	<head>
 	
 </head>
	<body>
		<iframe src="iframe.html" id="iframe1" />
	</body>
</html>



------------iframe.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


这篇关于如何从自我设置样式到iframe! ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆