473,555 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript">
var sc_project=2736 896;
var sc_invisible=0;
var sc_partition=0;
var sc_security="";
</script>

<script type="text/JavaScript" language="JavaS cript"
src="http://www.statcounter .com/counter/counter.js"></script><noscrip t><a
href="http://www.statcounter .com/" target="_blank" ><img
src="http://c1.statcounter. com/counter.php?sc_ project=273686& amp;java=0&amp; security=&amp;i nvisible=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 1479
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.ne t.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
15727
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
3147
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 interface without having them to change the text file themselves. (i.e., working on the supposition that the admin is IT illiterate). Simple...
4
2168
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 javascript, so this seemed a more appropriate place to post. I'm using a media=print style sheet to do a version of a web page that I am building....
2
4663
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 File\Print Preview in IE6 and noticed that occasionally the leftmost button of the javascript menu (CoolMenus Version 3.02) on our website is printed. (I...
1
1971
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 HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="/WEB-INF/tag-lib/struts-html-el.tld" prefix="html" %> <%@ taglib...
0
7622
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7547
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7825
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8060
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5452
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5171
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.