473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Can I add javascript to a stylesheet?

I am just about ok with html. Much less so with css. I have however used a
style sheet to link most of the pages in my website
--
Website http://www.tbandu.co.uk (TBandU short for Tuberculosis and You)

My question is:
I would like to add the following code for a visitor counter to my site
************************************************** ********
<!-- Start of StatCounter Code -->
<script type="text/JavaScript" language="JavaScript">
var sc_project=2736896;
var sc_invisible=0;
var sc_partition=0;
var sc_security="";
</script>

<script type="text/JavaScript" language="JavaScript"
src="http://www.statcounter.com/counter/counter.js"></script><noscript><a
href="http://www.statcounter.com/" target="_blank"><img
src="http://c1.statcounter.com/counter.php?sc_project=273686&amp;java=0&amp;secur ity=&amp;invisible=0"
alt="free web stats" border="0"></a> </noscript>
<!-- End of StatCounter Code -->
*********************************************

Is it possible to add it to my stylesheet? and if so how. Or will I have to
manually add it to every page?
Please bear in mind I am probably a 3 out of 10 in understanding css so
please keep replies "in english"
Thanks very much in advance and hope you never have to use my site!!!!
Mar 16 '06 #1
4 1477
nelly-knowall said on 16/03/2006 11:46 AM AEST:
I am just about ok with html. Much less so with css. I have however used a
style sheet to link most of the pages in my website

Putting the character sequence dash-dash-space-return at the start of a
line tells news reader programs that what follows is a signature block.
Everything below it is not quoted in a reply.

When I press 'reply' in my news reader, the new message contains only
the lines above, the rest I have to manually quote (bummer... I ain't
gunna) :-)

Anyhow, to answer your question: No.

The content of style and script elements is passed as-is to browser
program components for evaluation. The components expect to get valid
style rules or script statements respectively.

A style element (or external stylesheet) must follow the syntax rules
for CSS. You can't just randomly add HTML script elements or statements
inside style elements any more than you can randomly add CSS inside a
script element.

Having said that, CSS does support processing instructions to different
degrees in some browsers (and mostly for XML), but they are no
replacement for JavaScript and certainly should not be relied on by a
publicly accessed web site.
--
Rob
Mar 16 '06 #2
Sorry I don't understand the beginning of your reply dash dash dash stuff.
I put them in my original question. I didn't realise I was doing something
wrong
I understand the "no". But don't really understand the rest of your reply.
But thanks anyway.

"RobG" <rg***@iinet.net.au> wrote in message
news:GI******************@news.optus.net.au...
nelly-knowall said on 16/03/2006 11:46 AM AEST:
I am just about ok with html. Much less so with css. I have however
used a style sheet to link most of the pages in my website

Putting the character sequence dash-dash-space-return at the start of a
line tells news reader programs that what follows is a signature block.
Everything below it is not quoted in a reply.

When I press 'reply' in my news reader, the new message contains only the
lines above, the rest I have to manually quote (bummer... I ain't gunna)
:-)

Anyhow, to answer your question: No.

The content of style and script elements is passed as-is to browser
program components for evaluation. The components expect to get valid
style rules or script statements respectively.

A style element (or external stylesheet) must follow the syntax rules for
CSS. You can't just randomly add HTML script elements or statements
inside style elements any more than you can randomly add CSS inside a
script element.

Having said that, CSS does support processing instructions to different
degrees in some browsers (and mostly for XML), but they are no replacement
for JavaScript and certainly should not be relied on by a publicly
accessed web site.
--
Rob

Mar 16 '06 #3
nelly-knowall wrote:
Sorry I don't understand the beginning of your reply dash dash dash stuff.
I put them in my original question. I didn't realise I was doing something
wrong
I understand the "no". But don't really understand the rest of your reply.
But thanks anyway.

Most news readers treat signature blocks differently from the reset of a
message, they might appear greyed out and will not be included in replies.

Rob's saying that stylesheets can only contain valid CSS, in the same
way as JavaScript files can't contain CSS. The file type tells the
browser how to process the file. The browser's CSS engine won't know
how to deal with JavaScript.

--
Ian Collins.
Mar 16 '06 #4
nelly-knowall wrote:
^^^^^^^^^^^^^
So you know all?
I am just about ok with html. Much less so with css. I have however used
a style sheet to link most of the pages in my website


Interesting. (As in the curse: "May you live in interesting times."[1])

You have a rather long signature. You want to change this, trust me.
PointedEars
___________
[1] Which is _not_ a Chinese proverb, but probably of U.S. American origin.
Mar 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: George Hester | last post by:
I have a css file this is a portion of it: /* trackaccept.css */ div.track { width:400px; height: 100px; } I have this in my ASP page:
6
by: Jacqueline | last post by:
Hi, I would like to be able to write some code in Javascript preferably (PHP is also all right) which allows the admin of a website to be able to change stylesheet attributes from a GUI browser...
4
by: Julie Siebel | last post by:
Apologies...I'm sure this has been asked before, but I can't seem to come up with the correct Google search terms. While my problem is with stylesheets, the errors are being caused by my...
2
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing...
1
by: JumpingOffPlace | last post by:
Hi, I'm hoping that the wealth of knowledge here can stop me from spinning my wheels on this syntax error for hours. :) Below is the code, and the error I am recieving.... Code: <!DOCTYPE...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.