简体   繁体   中英

How to update the CSS of an iFrame with pure javascript not with jquery

I want to apply the custom CSS for the below iframe,

<iframe width="100%" class="freshwidget-embedded-form" id="freshwidget-embedded-form" src="http://customerservice.millers.com.au/widgets/feedback_widget/new?&amp;widgetType=embedded&amp;screenshot=no" scrolling="no" height="550px" frameborder="0"></iframe>

Please let me know how will i be able to modify the CSS of any class/element within the iFrame via JavaScript.

I think the question is not clear enough but I am going ahead and assume that you want to change the style or an attribute such as "src" using pure javascript,

So to change a style you have to grab the id or class then change the style, in your case it will be.

document.getElementById(freshwidget-embedded-form).style.width = "new_width"

or if you want to change the source it will be like

document.getElementById(freshwidget-embedded-form).src = "new src for the media"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM