Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font-family iFrame body

I've got an iFrame inside a body tag as follows:

<body onLoad="iFrameOn();">
    <iframe name="richTextField" id="richTextField" style="border:#000 1px solid; width:700px; height:300px;"></iframe>
</body>

The javascript iFrameOn looks like this:

function iFrameOn() {
    richTextField.document.designMode = 'On';
    richTextField.document.body.style.fontFamily = "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
}

Unfortunately, the font doesn't change to the font I tell it to change to. The error console from the javascript says: "Helvetica is not defined(...)". How can I solve this, so the font in the iFrame is the one I declare it to be?

Thanks in advance!

like image 292
Bram Avatar asked Sep 02 '25 16:09

Bram


1 Answers

you should set them as one string,

richTextField.document.body.style.fontFamily = 'Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif';
like image 141
Dejan.S Avatar answered Sep 05 '25 05:09

Dejan.S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!