Todd Bleeker's 12 Hive

All MindsharpBlogs

Are you pondering what I'm pondering?

My Links

Post Categories

Archives

Blog Stats

Style Under Cursor CEWP

Frequently, I have people ask me how to alter various elements of a Windows SharePoint Services (WSS) Web Part Page. To do this, you must first understand just a little about the HTML DOM (Document Object Model) rendered in the browser when you request a page from WSS. Fortunately, Microsoft (via ghosted direct-mode pages) has decorated the HTML elements on the default.aspx Web Part Page in a predictable and useful way. HTML tags often include "handles" (my word for element attributes like ID, Name, and Class) that you can use to gain access to and manipulate the DOM. One way to discover the handles available on a page is to view the HTML source of the current page (choose Source from the View menu in Internet Explorer). I frequently resort to this approach, but I am very familiar with HTML and the structure of a page. For a simpler approach, the Content Editor Web Part (CEWP) can lend some additional assistance.

My Style Under Cursor Web Part defines a table and populates it with values derived from attributes of the DOM element under the cursor. I'm sure that I wasn't the first, but I introduced the concept of viewing attributes of the element currently under the cursor using JavaScript in a browser in the FrontPage chapter (search for the section called “Changing Styles“) that I wrote for the SharePoint Resource Kit. Today there are some third party tools that can do this for any Web page (for instance, Firefox has a plug-in for viewing this kind of information) but I've extended the idea to include class parentage and improved the presentation and delivery for use within a CEWP. I'll save the technical details used in this Web Part for a future post so either import my StyleUnderCursor.DWP onto the home page of a WSS Team Site or paste the following code into the property builder behind the Source Editor... button of a CEWP you manually added to the page:

<script language="JavaScript">
function elementInfo()
{
  //Output CSS Class Hierarchy
  var currElement = window.event.srcElement;
  var classTree = "";
  var n = 50;

  //Show first n characters of tagName in TAG cell
  if(currElement.tagName != null)
  {
    ststag.innerText = "<" + currElement.tagName + ">";
    if(ststag.innerText.length > n)
      ststag.innerText = ststag.innerText.substring(1,n) + "...";
  }
  else
    ststag.innerText = "";

  //Show first n characters of id in ID cell
  if(currElement.id != null)
  {
    stsid.innerText = currElement.id;
    if(stsid.innerText.length > n)
      stsid.innerText = stsid.innerText.substring(0,n) + "...";
  }
  else
    stsid.innerText = "";

  //Show first n characters of name in NAME cell
  if(currElement.name != null)
  {
    stsname.innerText = currElement.name;
    if(stsname.innerText.length > n)
      stsname.innerText =
        stsname.innerText.substring(0,n) + "...";
  }
  else
    stsname.innerText = "";

  //Show entire class parentage in the CLASS cell
  if(currElement != null)
  {
    do
    {
      if(currElement.className != null &&
        currElement.className != "")
      {
        if(classTree != "")
          classTree = currElement.className + "\n" + classTree;
        else
          classTree = currElement.className;
      }
      currElement = currElement.parentElement;
    } while (currElement != null);
    stsclass.innerText = classTree;
  }
  else
  {
    stsclass.innerText = "";
  }
}

//Run code on all mouse over events
window.document.body.onmouseover = elementInfo;
</script>

<table border="1" width="100%" height="220">
  <tr>
    <td valign="top">
      <a href="
http://mindsharpblogs.com/Todd"
         target="_blank" Title="Todd's Blog">
        <img src="/_layouts/images/pagelogo.gif"
             border="0"></img></a>
    </td>
    <td valign="top" width="100%">
      <table>
        <tr>
          <td>TAG:</td>
          <td id="ststag" width="100%"></td>
        </tr>
        <tr>
          <td>ID:</td>
          <td id="stsid"></td>
        </tr>
        <tr>
          <td>NAME:</td>
          <td id="stsname"></td>
        </tr>
        <tr>
          <td valign="top">CLASS:</td>
          <td id="stsclass"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>

As you move your mouse over the page you should see details about the element under the cursor. Put your mouse over the Search textbox for an interesting set of information.

This is telling you that the element (Search textbox) under the cursor is an INPUT tag, it has a tag ID=idSearchString, it has a tag NAME=SearchString, and it is modified by the following four classes in this order: ms-main CSS class (on the TABLE that controls positioning of all elements on the page), then ms-titleareaframe CSS class (on three block elements namely a TD, a DIV, and a TABLE that contain the search form), then ms-searchform CSS class (on two more TDs), and finally ms-searchbox CSS class (on the INPUT element that defines the textbox itself). These CSS classes are initially defined in the 60 hive, farm-level 60\TEMPLATE\LAYOUTS\1033\STYLES\OWS.CSS file. I've listed the default theme definitions of these styles below:

.ms-main
{
}
.ms-titlearea
{
  font-family: verdana;
  font-size: 9pt;
}
TD.ms-titleareaframe
{
  color: black;
}
Div.ms-titleareaframe
{
  border-top: 3px solid #ffd275;
}
.ms-searchform
{
  background-color: #FFDF8C;
  font-family: verdana;
  font-size: 8pt;
}
.ms-searchbox
{
  background-color: #FFFFFF;
  font-family: verdana;
  font-size: 8pt;
}

Notice that the ms-main CSS class is initially empty. In fact, not every tag will have a element ID or an element NAME defined either. But most HTML elements on a WSS page have at least one CSS class attributed. Every CSS class that effects an element is listed in the Style Under Cursor CEWP from the first CSS class applied to the element to the last CSS class applied. If multiple attributions are made, they are reflected in the list. Since CSS classes cascade, the display characteristics defined at every level are used but the last definition of redundant characteristics are the ones used. For instance, background-color is defined in both ms-searchform and ms-searchbox but since ms-searchbox is the last CSS class attributed to the INPUT element the color #FFFFFF will be used. All definitions for the containing block elements CSS classes will be overridden by the definition in ms-searchbox.

Altering the last CSS class attributed will have the most precise effect while altering one of the container CSS classes will typically have a more wide-sweeping effect. For instance, altering the ms-main CSS class would effect the entire page unless an altered characteristic were overridden by a CSS class later in the page.

I rarely want to modify the Web Server based, farm-level OWS.CSS file in the 60 hive. Microsoft owns this file. So, key to this Web Part, if the same CSS class is defined more than once on a page, the last class defined will be used. Since these classes are initially defined in the OWS.CSS at the farm-level, if you created a redundant ms-searchbox CSS class later on the HTML page, the later characteristics would be used. For instance, if you placed the following code in the Style Over Cursor CEWP, above the JavaScript in this example, the Search textbox's background color would change to cyan:

Why? Because the last ms-searchbox CSS class defined on the page is in the CEWP. The farm-level CSS class is defined in the HEAD of the HTML. More on this when I describe how to Hide the Quick Launch in the next post.

<Todd />

posted on Tuesday, October 25, 2005 2:02 PM

Feedback

# Style Under Cursor CEWP by Todd Bleeker 10/26/2005 1:30 AM Alex's blog

# Style Under Cursor CEWP by Todd Bleeker 10/26/2005 1:55 AM Alexander Meijers

Todd wrote a nice article about showing styles when moving your cursor around. A lot of people asked...

# re: Style Under Cursor CEWP 10/26/2005 6:06 AM Shane Perran

Great post Todd.

# re: Style Under Cursor CEWP 10/26/2005 8:11 AM AC [MVP MCMS]

Have you seen the IE Developer Toolbar? May help with the "view source" part of your post. http://blogs.msdn.com/ie/archive/2005/09/16/469686.aspx

# Ie DevToolbar : so useful when you need to create some CSS mod 10/31/2005 12:20 PM Stramit's SharePoint Blog

# Ie DevToolbar : so useful when you need to create some CSS mod 10/31/2005 12:21 PM Stramit's SharePoint Blog

# re: Style Under Cursor CEWP 10/31/2005 4:57 PM Romeo Pruno

Some time ago I've write an interesting post about the interoperabiloity between "ClassInfo" and IE DevToolbar, for more information about it, please read this post at:
http://blogs.devleap.com/romeopruno/archive/2005/09/19/5792.aspx

# re: Style Under Cursor CEWP 11/1/2005 2:41 PM Todd Bleeker

Romeo,

Great minds think alike. The code that you posted in September is nearly identical to the code I've been giving away in my SharePoint developer class for over a year and a half, right down to the variable names and floating, absolutely positioned zindexed div.

<Todd />

# re: Bailing on ID Values, Progress with Design and Interface (CSS) 12/6/2005 11:14 AM SharePoint from Scratch

# Surfacing CSS Classes in SharePoint Pages 4/3/2007 7:36 PM Kathy Hughes

# re: Style Under Cursor CEWP 6/2/2008 5:42 AM Kız Oyunları

One way to discover the handles available on a page is to view the HTML source of the current page (choose Source from the View menu in Internet Explorer).
http://www.futboloyunlari.org
http://www.araba-oyunlari.com
http://www.arabaresim.net

# re: Style Under Cursor CEWP 6/5/2008 5:52 AM Youtube

thanks.great

# re: Style Under Cursor CEWP 6/18/2008 2:51 AM ms komut

css Cursor examples , Properties , Attribute - - http://css-lessons.ucoz.com/cursor-css-examples.htm

# re: Style Under Cursor CEWP 6/28/2008 7:28 PM Mirc

thanks you

# re: Style Under Cursor CEWP 6/29/2008 2:05 PM sohbet

Thanks..

# re: Style Under Cursor CEWP 7/16/2008 8:59 AM Chat

Thank you my friend..

# re: Style Under Cursor CEWP 7/20/2008 6:31 PM youtube

thanks.

# re: Style Under Cursor CEWP 8/9/2008 2:09 AM Çizgi Film

very good

# re: Style Under Cursor CEWP 8/9/2008 2:10 AM Reklam Ajans

very good

# re: Style Under Cursor CEWP 8/9/2008 2:10 AM web tasarım

very good

# re: Style Under Cursor CEWP 8/9/2008 2:12 AM film izle

very good

# re: Style Under Cursor CEWP 8/9/2008 2:13 AM Gelinlikler

very good

# re: Style Under Cursor CEWP 8/9/2008 2:14 AM masaüstü resimleri

very good

# re: Style Under Cursor CEWP 8/9/2008 2:14 AM Mercedes Yedek Parçaları

very good

# re: Style Under Cursor CEWP 8/9/2008 2:15 AM autocad kursu

very good

# re: Style Under Cursor CEWP 8/9/2008 2:15 AM Müzik Dinle

very good

# re: Style Under Cursor CEWP 8/9/2008 2:16 AM Havuz

very good

# re: Style Under Cursor CEWP 8/9/2008 2:17 AM Reseller

very good

# re: Style Under Cursor CEWP 8/9/2008 2:17 AM yemek tarifleri

very good

# re: Style Under Cursor CEWP 8/9/2008 2:17 AM havuz

very good

# re: Style Under Cursor CEWP 8/9/2008 2:18 AM film izle

very good

# re: Style Under Cursor CEWP 8/9/2008 2:19 AM otobüs firmaları

very good

# re: Style Under Cursor CEWP 8/9/2008 2:19 AM rüya tabiri

very good

# re: Style Under Cursor CEWP 8/9/2008 2:20 AM ilahi dinle

very good

# re: Style Under Cursor CEWP 8/9/2008 2:21 AM müzik dinle

very good

# re: Style Under Cursor CEWP 8/14/2008 10:06 AM gaziosmanpaşa

very good

# re: Style Undeer Cursor CEWP 9/10/2008 1:29 AM kabin

this is a pencil.

# chat 9/11/2008 9:45 AM chat

chat, sohbet siteleri

# bayrak 9/14/2008 6:36 AM bayrak

thanx

# film izle 9/14/2008 6:37 AM film izle

thanxx

# türk bayrağı 9/14/2008 6:37 AM türk bayrağı

thanxx

# re: Style Under Cursor CEWP 9/16/2008 1:17 AM mirc

thanks.

# re: Style Under Cursor CEWP 9/16/2008 1:20 AM mirc

thanks.

# re: Style Under Cursor CEWP 9/16/2008 4:26 AM chat

thanks.

# chat 9/20/2008 9:21 AM chat

thank you

# sohbet siteleri 9/20/2008 9:22 AM sohbet siteleri

tnks you

# netlog 9/20/2008 9:22 AM netlog

thnk you

# re: Style Under Cursor CEWP 9/21/2008 8:35 AM sac modelleri

thanks

# re: Style Under Cursor CEWP 9/22/2008 7:07 AM video

thanks

# oyun 9/22/2008 9:35 AM oyun

hello

# oyunlar 9/22/2008 9:36 AM oyunlar

THANKs

# oyun oyna 9/22/2008 9:36 AM oyun oyna

thanks

# Çocuk oyunları 9/22/2008 9:37 AM çocuk oyunları

cocuk-oyunlari

# işletme oyunları 9/22/2008 9:37 AM işletme oyunları

yhanks

# re: Style Under Cursor CEWP 9/23/2008 3:06 AM Makinapark

industrial, industry, industrie, accident, equipment, lighting, packaging, property, safety, supplies, electronics, flooring, products, chemical, furniture, health, accidents, hygiene, plastic, automotive, welding, woodworking, cutting, grinding, design, drilling, filling, heavy, food, second hand, paper, simple, machinery, machine, machines, maschinen, business, mastercam, router, training, cae, cnc, shirink, machinery, machine, machines, maschinen

# Yarış Oyunları 9/23/2008 6:29 AM Yarış Oyunları

hersey güzel olacak

# Macera Oyunları 9/23/2008 6:56 AM Macera Oyunları

güzel bir haraket bu

# Spor Oyunları 9/23/2008 7:01 AM Spor Oyunları

Spor Oyunlari

# Zeka Oyunları 9/23/2008 7:10 AM Zeka Oyunları

Zeka Oyunlari

# oyun oyna 9/23/2008 7:20 AM oyun oyna

Çocuk Oyunlari

# oyunlar 9/23/2008 7:21 AM oyunlar

thanks alot

# oyun 9/23/2008 7:21 AM oyun

thanks alot

# re: Style Under Cursor CEWP 9/24/2008 9:53 AM film indir

thanx very good

# re: Style Under Cursor CEWP 9/25/2008 2:57 PM Paralı Tavla

parali tavla play65 oyna

# re: Style Under Cursor CEWP 9/26/2008 4:09 AM aşkı memnu

thx

# re: Style Under Cursor CEWP 9/26/2008 8:43 PM oyun

i definately loved this thank you for the post it was very informative

# re: Style Under Cursor CEWP 9/27/2008 9:47 AM nike shoes

I need Thank you!

# Cafe Paylaşım 9/28/2008 10:14 AM paylaşım

thanks

# youtube 9/28/2008 3:34 PM youtube

good sharing thanx

# hack 9/28/2008 3:34 PM hack

good thank u

# uçak bileti 9/28/2008 3:35 PM uçak bileti

thank u i like it

# dizi izle 9/28/2008 3:35 PM dizi izle

thank good sharing

# şiir 9/28/2008 3:36 PM şiir

thanks good

# Oda oyunlari 10/1/2008 3:52 AM oda oyunlari

thanks

# re: Style Under Cursor CEWP 10/5/2008 2:32 AM sxe 7.0

Thanks good

# re: Style Under Cursor CEWP 10/5/2008 3:59 PM reseller

veri veri gülüm

# re: Style Under Cursor CEWP 10/7/2008 10:09 AM chat

thanlks

# porno izle 10/9/2008 3:14 PM porno izle

Thanks a lot !

# re: Style Under Cursor CEWP 10/11/2008 11:08 AM oyunlar

tesekkürler

# Estetik 10/12/2008 9:27 AM estetik cerrahi



i like this blog, thanks

# re: Style Under Cursor CEWP 10/13/2008 6:27 AM chat

thanks.

# re: Style Under Cursor CEWP 10/13/2008 6:28 AM chat

thanks.

# re: Style Under Cursor CEWP 10/16/2008 12:25 PM sohbet

Thank you very much

# re: Style Under Cursor CEWP 10/18/2008 4:31 AM mirc

thanks

# re: Style Under Cursor CEWP 10/19/2008 10:00 AM chat

tnks

# re: Style Under Cursor CEWP 10/19/2008 10:01 AM sohbet

tnks

# re: Style Under Cursor CEWP 10/20/2008 12:54 AM mirc indir

Thanks

# re: Style Under Cursor CEWP 10/20/2008 9:04 AM mirc ekle

Thanks

# re: Style Under Cursor CEWP 10/20/2008 3:06 PM mirc ekle

Thanks

# re: Style Under Cursor CEWP 10/20/2008 3:06 PM mirc ekle

Thanks

# re: Style Under Cursor CEWP 10/20/2008 3:07 PM mircada

Thanks

# re: Style Under Cursor CEWP 10/21/2008 4:24 AM mirc

Thanks

# re: Style Under Cursor CEWP 10/22/2008 2:16 AM catlak

Thanks

# sex hikayeleri 10/22/2008 2:52 AM sex hikayeleri

Thanks a lot

# src belgesi 10/22/2008 4:49 PM src belgesi

src belgesi

# sürücü kursu 10/22/2008 4:50 PM sürücü kursu

sürücü kursu

# araba oyunu 10/22/2008 4:50 PM araba oyunu

araba oyunu

# ehliyet 10/22/2008 4:51 PM ehliyet

ehliyet

# kayıp prenses oyunları 10/22/2008 4:52 PM kayıp prenses oyunları

kayip prenses oyunlari

# tır oyunları 10/22/2008 4:53 PM tır oyunları

tir oyunlari

# re: Style Under Cursor CEWP 10/24/2008 6:07 AM sohbet

thank you

# re: Style Under Cursor CEWP 10/25/2008 5:40 PM oyun

Thanks

# re: Style Under Cursor CEWP 10/26/2008 3:27 AM pornolar

thanx man

# re: Style Under Cursor CEWP 10/28/2008 10:25 PM erotik videolar

onlardan thanks dielim very good!

# re: Style Under Cursor CEWP 10/29/2008 1:37 AM mzik dinle

I liked to read it. it was verry wel written.

# re: Style Under Cursor CEWP 10/29/2008 1:38 AM müzik dinle

I liked to read it. it was verry wel written.

# re: Style Under Cursor CEWP 10/29/2008 1:38 AM radyo dinle

I liked to read it. it was verry wel written.

# re: Style Under Cursor CEWP 10/29/2008 1:38 AM sohbet

I liked to read it. it was verry wel written.

# re: Style Under Cursor CEWP 10/30/2008 5:31 AM ilaçlama

very good!

# re: Style Under Cursor CEWP 10/30/2008 5:33 AM cozumilaclama

veryy good!!

# re: Style Under Cursor CEWP 10/31/2008 2:42 AM ilaclama

ilaclama Hizmetleri

http://www.berfinilaclama.com
http://www.bocekilaclama.gen.tr
http://www.etkinilaclama.net

# re: Style Under Cursor CEWP 11/1/2008 9:59 AM estetik


http://www.estetiks.com/ Estetik
http://www.estetik.ws/ Estetik
http://www.estetikameliyat.com/ Estetik

# re: Style Under Cursor CEWP 11/12/2008 3:19 AM hekimboard

thanks a lot.

# re: Style Under Cursor CEWP 11/12/2008 3:41 AM seks hikaye

good post.i like this blog, thanks

# re: Style Under Cursor CEWP 11/13/2008 3:28 AM güvenlik

thanks.

# re: Style Under Cursor CEWP 11/13/2008 6:14 PM izlesene

saolasin canim yaw

# re: Style Under Cursor CEWP 11/17/2008 11:15 AM filim

LIKE VERY MUCH, BEATIFULL, ONE, WRITING,

# re: Style Under Cursor CEWP 11/17/2008 11:17 AM müzik dinle

LIKE VERY MUCH, BEATIFULL, ONE, WRITING,

# re: Style Under Cursor CEWP 11/17/2008 12:19 PM Chat

confirmed it is now too late for Ron Paul to remove himself as a candidate, and that he will remain as the Presidential candidate for the Constitution Party of Montana on the November ballot. So, let's crank it up!

# re: Style Under Cursor CEWP 11/17/2008 12:19 PM Sohbet

confirmed it is now too late for Ron Paul to remove himself as a candidate, and that he will remain as the Presidential candidate for the Constitution Party of Montana on the November ballot. So, let's crank it up!

# re: Style Under Cursor CEWP 11/17/2008 7:13 PM key ödemeleri

<a href="http://www.turkudinle.gen.tr">bedava türkü dinle</a> thanks.

# re: Style Under Cursor CEWP 11/17/2008 7:14 PM türkü dinle

Thanks.

# re: Style Under Cursor CEWP 11/17/2008 7:15 PM radyo dinle

Thanks.

# re: Style Under Cursor CEWP 11/17/2008 7:15 PM müzik dinle

Thanks.

# re: Style Under Cursor CEWP 11/17/2008 7:16 PM türkü sözleri

thanks.

Title  
Name  
Url
CAPTCHA
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments