开发者

Can I overwrite table background color inside an iframe?

I have used an <iframe> with external src. Can I overwrite the table background color开发者_StackOverflow of that external page?


css declarations in the HTML page override those that are declared in external .css files. So, if you add something like this in the part of html:

<style type="text/css">
   //some css here
 </style>

the duplicate values will be overriding declarations from your css file.


First, I want to ask you why you are using an iframe. Instead, you can use jQuery ajax, which overlays your iframe code. Nowadays people don’t use iframes much as they have many limitations.

By using ajax load, you can access the child page Javascript and vice versa.

The following code may help you to achieve this effect

<html>
<body>
<table id="x" bgcolor="red">
    <tr><td>Vikas</td></tr>
</table>
<script>
    change("blue");
    function change(color)
    {
        document.getElementById("x").setAttribute("bgcolor", color);
    }
</script>
</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜