I have an iframe tag, where I wish to change the font-family. But the iframe I am linking to does not have a body, it's just text and pictures. So most javascript ways of accessing it don't work. Is there any way around it?
            Asked
            
        
        
            Active
            
        
            Viewed 102 times
        
    -2
            
            
        - 
                    Is the iframe on the same domain as its parent? – Prisoner May 02 '13 at 13:58
- 
                    @Prisoner no it is not – Nicolaid May 02 '13 at 13:59
- 
                    Possible duplicate: http://stackoverflow.com/questions/217776/how-to-apply-css-to-iframe (and many others) – Cedric Reichenbach May 02 '13 at 14:09
2 Answers
2
            
            
        If the iframe isn't on the same domain as its parent, there's nothing you can do to modify its contents, because of the same-origin policy.
 
    
    
        Elliot Bonneville
        
- 51,872
- 23
- 96
- 123
- 
                    https://developer.mozilla.org/en-US/docs/JavaScript/Same_origin_policy_for_JavaScript – Ian May 02 '13 at 14:10
- 
                    
0
            If the iFrame is not on the same URL / server, the best way for you do this is with PHP instead.
<div class="iframe">
    <?php echo get_file_contents("http://www.google.com"); ?>
</div>
<style>
    .iframe {
        !! Whatever Styles !!
    }
</style>
Obviously replacing !! Whatever Styles !! with the changes you wish to make to the font. I hope this helped - I'm quite new to Stack Overflow, so if I'm doing anything wrong please tell me :)
 
    
    
        VCNinc
        
- 747
- 1
- 9
- 25
