Chubzx
Chubzx

Reputation: 1

How to change colours within iframe loaded page

<html>
<body>
<style type="text/css">

</style>

<iframe src="http://connectotravel.com/" height="100%" width="100%" id="frame">  </iframe>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$.frameReady( function() {


);
</script>
</body>
</html>

What I want to do is to change the background color within this iframe using jquery. Any help will do.

Upvotes: 0

Views: 222

Answers (1)

Aravind.HU
Aravind.HU

Reputation: 9472

You can do it with contents API of Jquery library

Just add this with in the script tag ( you please change the colour code with your desired colour number )

$( document ).ready(function() {
    $("#frame").contents().find("body").css("background-color", "#BADA55");
});

If this didnt work you can also try by finding html element itself

$( document ).ready(function() { 
     $("#frame").contents().find("html").css("background-color", "#BADA55");
}

References : - Iframe content access via jquery

Upvotes: 1

Related Questions