Last post Feb 08, 2017 04:52 PM by bruce (sqlwork.com)
Member
17 Points
70 Posts
Feb 08, 2017 08:30 AM|NAF|LINK
im able to change the background color of the page inside of the iframe when i write the below code :
document.getElementById("if1").contentWindow.frames[1].document.querySelector("body").style.backgroundColor = "red";
but im not able to change the font size , below is the code for changing the font size :
<script type="text/javascript"> function changeSize() { document.getElementById("if1").contentWindow.frames[1].document.querySelector("body").style.fontSize = "200%"; }
All-Star
31362 Points
7055 Posts
Feb 08, 2017 11:13 AM|kaushalparik27|LINK
Please let us know in which event or action you are trying to call - changeSize()
Feb 08, 2017 12:15 PM|NAF|LINK
on link click :
<a href="javascript:changeSize();">+</a>
i even am able to change the color of the text using the below :
function changeSize() { document.getElementById("if1").contentWindow.frames[1].document.querySelector("body").style.cssText = 'color:red !important'; }
but can not manage to change the font size :(
Feb 08, 2017 12:23 PM|kaushalparik27|LINK
document.getElementById("if1").contentWindow.frames[1].document.querySelector("body").style.fontSize = "200%";
Did you try setting fontSize like '35px' to see if that makes any effect?
also, try to write like:
document.getElementById("if1").contentWindow.document["body"].style.fontSize = "200%";
Feb 08, 2017 12:33 PM|NAF|LINK
the first option you gave me i already tried it but no results
as for the second , surely it wont work as if1 is the main iframe , and inside of it there are 2 frames , im targeting frame [1]
strange that i can cchange the background color , or the color of the text buti cant change the font size :(
Feb 08, 2017 12:59 PM|kaushalparik27|LINK
Try adding styles together
document.getElementById("if1").contentWindow.frames[1].document.querySelector("body").style = "background-color: red; font-size: 200% !important";
Feb 08, 2017 01:04 PM|NAF|LINK
it changed the background color but didnt change the font size :(
57854 Points
15488 Posts
Feb 08, 2017 04:52 PM|bruce (sqlwork.com)|LINK
NAF it changed the background color but didnt change the font size :(
use the browser debugger to see the styles applied to iframe content. most likely, text on the page is overriding body.
Member
17 Points
70 Posts
font size not changing in IFrame page
Feb 08, 2017 08:30 AM|NAF|LINK
im able to change the background color of the page inside of the iframe when i write the below code :
but im not able to change the font size , below is the code for changing the font size :
All-Star
31362 Points
7055 Posts
Re: font size not changing in IFrame page
Feb 08, 2017 11:13 AM|kaushalparik27|LINK
Please let us know in which event or action you are trying to call - changeSize()
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Member
17 Points
70 Posts
Re: font size not changing in IFrame page
Feb 08, 2017 12:15 PM|NAF|LINK
on link click :
<a href="javascript:changeSize();">+</a>
i even am able to change the color of the text using the below :
but can not manage to change the font size :(
All-Star
31362 Points
7055 Posts
Re: font size not changing in IFrame page
Feb 08, 2017 12:23 PM|kaushalparik27|LINK
document.getElementById("if1").contentWindow.frames[1].document.querySelector("body").style.fontSize = "200%";
Did you try setting fontSize like '35px' to see if that makes any effect?
also, try to write like:
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Member
17 Points
70 Posts
Re: font size not changing in IFrame page
Feb 08, 2017 12:33 PM|NAF|LINK
the first option you gave me i already tried it but no results
as for the second , surely it wont work as if1 is the main iframe , and inside of it there are 2 frames , im targeting frame [1]
strange that i can cchange the background color , or the color of the text buti cant change the font size :(
All-Star
31362 Points
7055 Posts
Re: font size not changing in IFrame page
Feb 08, 2017 12:59 PM|kaushalparik27|LINK
Try adding styles together
document.getElementById("if1").contentWindow.frames[1].document.querySelector("body").style = "background-color: red; font-size: 200% !important";
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Member
17 Points
70 Posts
Re: font size not changing in IFrame page
Feb 08, 2017 01:04 PM|NAF|LINK
it changed the background color but didnt change the font size :(
All-Star
57854 Points
15488 Posts
Re: font size not changing in IFrame page
Feb 08, 2017 04:52 PM|bruce (sqlwork.com)|LINK
use the browser debugger to see the styles applied to iframe content. most likely, text on the page is overriding body.