Home All Groups Group Topic Archive Search About

Where to put code to change scroll bar color

Author
12 Jun 2009 1:03 PM
AAaron123
In Sub Page_PreRender I do:

Response.Write("<script type='text/javascript'>")

Response.Write("var htmlStyle =
document.getElementsByTagName('html')[0].style;")

Response.Write("htmlStyle.scrollbarBaseColor = 'black';")

or sometimes the last line is:

Response.Write("htmlStyle.scrollbarBaseColor = 'blue;")

This works in IE. I don't think it works in any other browser, but I'm not
sure.\



In any event the sourse in the browsers looks like:

     <script type='text/javascript'>var htmlStyle =
document.getElementsByTagName('html')[0].style;htmlStyle.scrollbarBaseColor
= 'black';</script>

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
      ...

      Appears to work OK but it seems unnatural for my text to be before the
DOCTYPE.

      Is that OK?

      Can you suggest a better way to do this - other than: not changing the
color :-))

      Thanks

Author
12 Jun 2009 1:27 PM
Patrice
I would use CSS rather than JavaScript...
http://www.webdevelopersnotes.com/tips/html/css_scrollbar_color_code.php3

Technically speaking Response.Write should not be used in ASP.NET as you
have no way to tell where to insert your code. See Page.ClientScript that
exposes several methods allowing to inject the script at the proper place...

--
Patrice

"AAaron123" <aaaron***@roadrunner.com> a écrit dans le message de groupe de
discussion : #sYU9416JHA.1***@TK2MSFTNGP06.phx.gbl...
Show quoteHide quote
> In Sub Page_PreRender I do:
>
> Response.Write("<script type='text/javascript'>")
>
> Response.Write("var htmlStyle =
> document.getElementsByTagName('html')[0].style;")
>
> Response.Write("htmlStyle.scrollbarBaseColor = 'black';")
>
> or sometimes the last line is:
>
> Response.Write("htmlStyle.scrollbarBaseColor = 'blue;")
>
> This works in IE. I don't think it works in any other browser, but I'm not
> sure.\
>
>
>
> In any event the sourse in the browsers looks like:
>
>     <script type='text/javascript'>var htmlStyle =
> document.getElementsByTagName('html')[0].style;htmlStyle.scrollbarBaseColor
> = 'black';</script>
>
>     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
>      ...
>
>      Appears to work OK but it seems unnatural for my text to be before
> the DOCTYPE.
>
>      Is that OK?
>
>      Can you suggest a better way to do this - other than: not changing
> the color :-))
>
>      Thanks
>
>
>
>
>
>
>
>
>
>
Are all your drivers up to date? click for free checkup

Author
12 Jun 2009 9:03 PM
AAaron123
While implementing your suggestion something strange showed up.

Once I removed the script lines my asp:Menu developed a problem.

I would appreciate it if you'd look at my last post under
"asp:Menu control does not work well in all browsers"




Another thing is that I got the following error when I implemented code in
webdevelopersnotes.

Error 3 Validation (CSS 2.1): 'scrollbar-base-color' is not a known CSS
property name.

But it works ok!

Make sense to you?

Thanks


Show quoteHide quote
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:A95F9766-4813-40E7-9E7B-BAA97A60EAB6@microsoft.com...
>I would use CSS rather than JavaScript...
>http://www.webdevelopersnotes.com/tips/html/css_scrollbar_color_code.php3
>
> Technically speaking Response.Write should not be used in ASP.NET as you
> have no way to tell where to insert your code. See Page.ClientScript that
> exposes several methods allowing to inject the script at the proper
> place...
>
> --
> Patrice
>
> "AAaron123" <aaaron***@roadrunner.com> a écrit dans le message de groupe
> de discussion : #sYU9416JHA.1***@TK2MSFTNGP06.phx.gbl...
>> In Sub Page_PreRender I do:
>>
>> Response.Write("<script type='text/javascript'>")
>>
>> Response.Write("var htmlStyle =
>> document.getElementsByTagName('html')[0].style;")
>>
>> Response.Write("htmlStyle.scrollbarBaseColor = 'black';")
>>
>> or sometimes the last line is:
>>
>> Response.Write("htmlStyle.scrollbarBaseColor = 'blue;")
>>
>> This works in IE. I don't think it works in any other browser, but I'm
>> not sure.\
>>
>>
>>
>> In any event the sourse in the browsers looks like:
>>
>>     <script type='text/javascript'>var htmlStyle =
>> document.getElementsByTagName('html')[0].style;htmlStyle.scrollbarBaseColor
>> = 'black';</script>
>>
>>     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>>     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
>>      ...
>>
>>      Appears to work OK but it seems unnatural for my text to be before
>> the DOCTYPE.
>>
>>      Is that OK?
>>
>>      Can you suggest a better way to do this - other than: not changing
>> the color :-))
>>
>>      Thanks
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
Author
15 Jun 2009 8:20 AM
Patrice
This is a warning. Remember that changing the scrollbar color is not part of
the standard...

--
Patrice

"AAaron123" <aaaron***@roadrunner.com> a écrit dans le message de groupe de
discussion : OCGewE66JHA.2***@TK2MSFTNGP02.phx.gbl...
Show quoteHide quote
> While implementing your suggestion something strange showed up.
>
> Once I removed the script lines my asp:Menu developed a problem.
>
> I would appreciate it if you'd look at my last post under
> "asp:Menu control does not work well in all browsers"
>
>
>
>
> Another thing is that I got the following error when I implemented code in
> webdevelopersnotes.
>
> Error 3 Validation (CSS 2.1): 'scrollbar-base-color' is not a known CSS
> property name.
>
> But it works ok!
>
> Make sense to you?
>
> Thanks
>
>
> "Patrice" <http://www.chez.com/scribe/> wrote in message
> news:A95F9766-4813-40E7-9E7B-BAA97A60EAB6@microsoft.com...
>>I would use CSS rather than JavaScript...
>>http://www.webdevelopersnotes.com/tips/html/css_scrollbar_color_code.php3
>>
>> Technically speaking Response.Write should not be used in ASP.NET as you
>> have no way to tell where to insert your code. See Page.ClientScript that
>> exposes several methods allowing to inject the script at the proper
>> place...
>>
>> --
>> Patrice
>>
>> "AAaron123" <aaaron***@roadrunner.com> a écrit dans le message de groupe
>> de discussion : #sYU9416JHA.1***@TK2MSFTNGP06.phx.gbl...
>>> In Sub Page_PreRender I do:
>>>
>>> Response.Write("<script type='text/javascript'>")
>>>
>>> Response.Write("var htmlStyle =
>>> document.getElementsByTagName('html')[0].style;")
>>>
>>> Response.Write("htmlStyle.scrollbarBaseColor = 'black';")
>>>
>>> or sometimes the last line is:
>>>
>>> Response.Write("htmlStyle.scrollbarBaseColor = 'blue;")
>>>
>>> This works in IE. I don't think it works in any other browser, but I'm
>>> not sure.\
>>>
>>>
>>>
>>> In any event the sourse in the browsers looks like:
>>>
>>>     <script type='text/javascript'>var htmlStyle =
>>> document.getElementsByTagName('html')[0].style;htmlStyle.scrollbarBaseColor
>>> = 'black';</script>
>>>
>>>     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>>>     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>>     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
>>>      ...
>>>
>>>      Appears to work OK but it seems unnatural for my text to be before
>>> the DOCTYPE.
>>>
>>>      Is that OK?
>>>
>>>      Can you suggest a better way to do this - other than: not changing
>>> the color :-))
>>>
>>>      Thanks
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
>
Author
15 Jun 2009 12:29 PM
AAaron123
Thanks a lot

Show quoteHide quote
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:7E0E2E48-1CDB-404C-A009-6CE772AB6664@microsoft.com...
> This is a warning. Remember that changing the scrollbar color is not part
> of the standard...
>
> --
> Patrice
>
> "AAaron123" <aaaron***@roadrunner.com> a écrit dans le message de groupe
> de discussion : OCGewE66JHA.2***@TK2MSFTNGP02.phx.gbl...
>> While implementing your suggestion something strange showed up.
>>
>> Once I removed the script lines my asp:Menu developed a problem.
>>
>> I would appreciate it if you'd look at my last post under
>> "asp:Menu control does not work well in all browsers"
>>
>>
>>
>>
>> Another thing is that I got the following error when I implemented code
>> in webdevelopersnotes.
>>
>> Error 3 Validation (CSS 2.1): 'scrollbar-base-color' is not a known CSS
>> property name.
>>
>> But it works ok!
>>
>> Make sense to you?
>>
>> Thanks
>>
>>
>> "Patrice" <http://www.chez.com/scribe/> wrote in message
>> news:A95F9766-4813-40E7-9E7B-BAA97A60EAB6@microsoft.com...
>>>I would use CSS rather than JavaScript...
>>>http://www.webdevelopersnotes.com/tips/html/css_scrollbar_color_code.php3
>>>
>>> Technically speaking Response.Write should not be used in ASP.NET as you
>>> have no way to tell where to insert your code. See Page.ClientScript
>>> that exposes several methods allowing to inject the script at the proper
>>> place...
>>>
>>> --
>>> Patrice
>>>
>>> "AAaron123" <aaaron***@roadrunner.com> a écrit dans le message de groupe
>>> de discussion : #sYU9416JHA.1***@TK2MSFTNGP06.phx.gbl...
>>>> In Sub Page_PreRender I do:
>>>>
>>>> Response.Write("<script type='text/javascript'>")
>>>>
>>>> Response.Write("var htmlStyle =
>>>> document.getElementsByTagName('html')[0].style;")
>>>>
>>>> Response.Write("htmlStyle.scrollbarBaseColor = 'black';")
>>>>
>>>> or sometimes the last line is:
>>>>
>>>> Response.Write("htmlStyle.scrollbarBaseColor = 'blue;")
>>>>
>>>> This works in IE. I don't think it works in any other browser, but I'm
>>>> not sure.\
>>>>
>>>>
>>>>
>>>> In any event the sourse in the browsers looks like:
>>>>
>>>>     <script type='text/javascript'>var htmlStyle =
>>>> document.getElementsByTagName('html')[0].style;htmlStyle.scrollbarBaseColor
>>>> = 'black';</script>
>>>>
>>>>     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>>>>     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>>>     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
>>>>      ...
>>>>
>>>>      Appears to work OK but it seems unnatural for my text to be before
>>>> the DOCTYPE.
>>>>
>>>>      Is that OK?
>>>>
>>>>      Can you suggest a better way to do this - other than: not changing
>>>> the color :-))
>>>>
>>>>      Thanks
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>
Author
15 Jun 2009 5:33 PM
Alan Silver
In article <OCGewE66JHA.2***@TK2MSFTNGP02.phx.gbl>, AAaron123
<aaaron***@roadrunner.com> writes
>Another thing is that I got the following error when I implemented code
>in webdevelopersnotes.
>
>Error 3 Validation (CSS 2.1): 'scrollbar-base-color' is not a known CSS
>property name.
>
>But it works ok!
>
>Make sense to you?

Sure it makes sense. Microsoft invented this, and it is not valid CSS.
That's why only IE supports it. The W3C never accepted it, mainly
because they don't like this sort of idea...

As an aside, I know you don't want to hear this, but changing the colour
of parts of the user's UI is a really bad idea. It's about as
user-friendly as changing the size of the browser window (ooh, I *hate*
that!), popping open a new window with no menu, toolbar, etc and a whole
pile of other things guaranteed to annoy your users!

In short, I wouldn't do it, unless you want to encourage them to hit the
Back button pretty fast!

--
Alan Silver
(anything added below this line is nothing to do with me)
Author
15 Jun 2009 7:04 PM
Mark Rae [MVP]
"Alan Silver" <alan-silver@nospam.thanx.invalid> wrote in message
news:zsJ3N5MPXoNKFweL@nospamthankyou.spam...

> As an aside, I know you don't want to hear this, but changing the colour
> of parts of the user's UI is a really bad idea. It's about as
> user-friendly as changing the size of the browser window (ooh, I *hate*
> that!), popping open a new window with no menu, toolbar, etc and a whole
> pile of other things guaranteed to annoy your users!

Agreed 100%.


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Author
15 Jun 2009 11:52 PM
AAaron123
Show quote Hide quote
"Mark Rae [MVP]" <mark@markNOSPAMrae.net> wrote in message
news:uxlKewe7JHA.5008@TK2MSFTNGP05.phx.gbl...
> "Alan Silver" <alan-silver@nospam.thanx.invalid> wrote in message
> news:zsJ3N5MPXoNKFweL@nospamthankyou.spam...
>
>> As an aside, I know you don't want to hear this, but changing the colour
>> of parts of the user's UI is a really bad idea. It's about as
>> user-friendly as changing the size of the browser window (ooh, I *hate*
>> that!), popping open a new window with no menu, toolbar, etc and a whole
>> pile of other things guaranteed to annoy your users!
>
> Agreed 100%.
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
I'll take your word for this but to me it looks very much better if the
colors all go together.

But I understand you both have much more experience.

Thanks
Author
16 Jun 2009 12:57 PM
Alan Silver
In article <O7mtqRh7JHA.2***@TK2MSFTNGP05.phx.gbl>, AAaron123
<aaaron***@roadrunner.com> writes
>I'll take your word for this but to me it looks very much better if the
>colors all go together.

Colours going together is great for the page content, but that doesn't
mean that the browser has to match.

Users like a consistent and predictable experience. That's one reason
why someone used to Windows will be able to pick up a new program fairly
quickly (assuming it was written properly) as they will be used to the
idiom. Change the idiom, and you confuse people. Believe it or not, this
includes such simple things as the colour of the scroll bars!

>But I understand you both have much more experience.

Been a web designer for about 17 years, and read a *lot* of books on
usability and the human/machine interface. You get a bit evangelical
about subject like this after a while!

Ta ra

--
Alan Silver
(anything added below this line is nothing to do with me)
Author
16 Jun 2009 4:57 PM
AAaron123
Show quote Hide quote
"Alan Silver" <alan-silver@nospam.thanx.invalid> wrote in message
news:Ud$uhUOVb5NKFwIT@nospamthankyou.spam...
> In article <O7mtqRh7JHA.2***@TK2MSFTNGP05.phx.gbl>, AAaron123
> <aaaron***@roadrunner.com> writes
>>I'll take your word for this but to me it looks very much better if the
>>colors all go together.
>
> Colours going together is great for the page content, but that doesn't
> mean that the browser has to match.
>
> Users like a consistent and predictable experience. That's one reason why
> someone used to Windows will be able to pick up a new program fairly
> quickly (assuming it was written properly) as they will be used to the
> idiom. Change the idiom, and you confuse people. Believe it or not, this
> includes such simple things as the colour of the scroll bars!
>
>>But I understand you both have much more experience.
>
> Been a web designer for about 17 years, and read a *lot* of books on
> usability and the human/machine interface. You get a bit evangelical about
> subject like this after a while!
>
> Ta ra
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)

Thanks for all the help



Post Thread options