tags:

views:

236

answers:

6

Is it possible to change the style of the scrollbars of on iframe?

i tried to style it by using the following code but it doesnt seem to work

html{scrollbar-arrow-color: #252604;
 scrollbar-highlight-color: #BFC097;
 scrollbar-shadow-color: #ffffff;
 scrollbar-base-color : #000000;
 scrollbar-track-color: #E2E1D4;
 scrollbar-face-color: #BFC097;
 scrollbar-3dlight-color: #EFEEEE;
 scrollbar-darkshadow-color: #999999;}

and tried

body{scrollbar-arrow-color: #252604;
 scrollbar-highlight-color: #BFC097;
 scrollbar-shadow-color: #ffffff;
 scrollbar-base-color : #000000;
 scrollbar-track-color: #E2E1D4;
 scrollbar-face-color: #BFC097;
 scrollbar-3dlight-color: #EFEEEE;
 scrollbar-darkshadow-color: #999999;}

Have I got it wrong? just one more thing the file in the iframe is in a different domain? i have had experiences where javascript didnt work but will it affect CSS as well??

A: 

AFAIK, you can't do this in a cross browser way. I think the code you have used above will work in IE only.

rahul
i have tried this on ie and it didnt work.......
manraj82
+2  A: 

Try iframe body, not just body.

This will work perfectly in Webkit browsers(Safari & Chrome), don't think there'll be a cross browser solution. Well - you could with Javascript!

Jonny Haynes
Those webkit scrollbars are cool. PS, they work in Chrome too!
Andy E
Yeah - I meant to put Webkit - Edited
Jonny Haynes
A: 

Just lose the iframe or any way of styling scrollbars, it's just not done.

Daniel Boomgaardt
A: 

Using javascript (i.e. jScrollPane) is the only cross-browser option of styling scrollbars, I'm afraid.

Raveren
+1  A: 

There is no cross-browser way to style the scrollbars.

The code that you have only works in Internet Explorer, and only in quirks (non-standard) mode.

What you have in the iframe is isolated from the main page, you have to style the scrollbars on the page where they appear, i.e. in the page that you load in the iframe. Any styling that you apply to the main page does not affect what's in the iframe.

If you can't change the content of the page that you load in the iframe, it's not possible to style it's scrollbars.

Guffa
Jonny Haynes
@Jonny: If the page would have been from the same domain, that would have been possible.
Guffa
okay - cool - thanks for the pointer!
Jonny Haynes
yeah i thought that would be the case,i wasn't really sure about the cross domain issue..but thanks for pointing it out though.
manraj82
However, adding style to the scroll bars **IS** possible using JavaScript (see my answer)
Raveren
@Raveren: Yes, you can replace the scrollbars, but it's not possible to use when the page is loaded from a different domain and you can't change the page.
Guffa
Well theoretically you CAN access the iframe via javascript - *and* its contents - I'm pretty sure (although haven't tested) that it'd be possible to alter the content - along with the scrollbars. Please correct me if I am wrong..
Raveren
@Raveren: If the page loaded in the iframe is from a diffrerent domain (which happens to be the case here), you can't do anything at all with it.
Guffa
Interesting to know, that's new to me, thanks.
Raveren
A: 

You need to add the CSS to the actual page in the iframe, i.e. if you have page.html and iframe.html then the CSS must be in iframe.html.

However, don't rely on that CSS, it only works in IE, or Opera under quirks mode.

DisgruntledGoat