Where to put code to change scroll bar color


A

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
 
Ad

Advertisements

A

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


Patrice said:
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 said:
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
 
A

AAaron123

Thanks a lot

Patrice said:
This is a warning. Remember that changing the scrollbar color is not part
of the standard...

--
Patrice

AAaron123 said:
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 said:
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" <[email protected]> a écrit dans le message de groupe
de discussion : #[email protected]
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
 
A

AAaron123

Mark Rae said:
Agreed 100%.
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
 
Ad

Advertisements

A

AAaron123

Alan Silver said:
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!


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

Thanks for all the help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top