473,386 Members | 1,752 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.

Javascipt code shows up in Firefox...

I just added a Google ad to my web page, and it now looks like this:
http://arancaytar.ermarian.net/

The javascript code that formats the ad is actually visible on the page
itself, just above the ad. This is in spite of it being commented out I
looked at the source which has something like this:

<script type="text/javascript">
<!--
....
//-->
</script>

The script is apparently executed (because the settings affect the
color of the ad), but it's nonetheless shown on the page. At least in
Firefox, IE hides it.

What bothers me most is that the page nonetheless validates as XHTML.
Can anyone see the mistake?

Jan 4 '07 #1
9 1956
Arancaytar wrote:
I just added a Google ad to my web page, and it now looks like this:
http://arancaytar.ermarian.net/

The javascript code that formats the ad is actually visible on the page
itself, just above the ad. This is in spite of it being commented out I
looked at the source which has something like this:

<script type="text/javascript">
<!--
...
//-->
</script>

The script is apparently executed (because the settings affect the
color of the ad), but it's nonetheless shown on the page. At least in
Firefox, IE hides it.
It is your CSS, you have a rule at line 284 in themes/garland/style.css
with selector #header-region * that sets
display: inline;
and Mozilla seems to apply that then although it does not seem to make
much sense to change such settings on script elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 4 '07 #2
Scripsit Martin Honnen:
><script type="text/javascript">
<!--
...
//-->
</script>
- -
It is your CSS, you have a rule at line 284 in
themes/garland/style.css with selector #header-region * that sets
display: inline;
and Mozilla seems to apply that then although it does not seem to make
much sense to change such settings on script elements.
Well spotted. There's the additional problem that using <!-- and --to
"comment out" the code is simply wrong in XHTML (and hasn't been useful in
HTML either _for years_). It may _actually_ comment out the code so that the
browser won't see it at all. Of course, the markup still _validates_, since
validation does not deal with such issues.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jan 4 '07 #3

Jukka K. Korpela wrote:
Scripsit Martin Honnen:
- -
It is your CSS, you have a rule at line 284 in
themes/garland/style.css with selector #header-region * that sets
display: inline;
and Mozilla seems to apply that then although it does not seem to make
much sense to change such settings on script elements.

Well spotted. There's the additional problem that using <!-- and --to
"comment out" the code is simply wrong in XHTML (and hasn't been useful in
HTML either _for years_). It may _actually_ comment out the code so that the
browser won't see it at all. Of course, the markup still _validates_, since
validation does not deal with such issues.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Thanks very much for that. I never would have seen it (I didn't even
know wildcards were allowed in CSS...)

And thanks for the heads-up on comments in script tags; I'll make sure
to take that into account in the future. This code isn't mine, so I'll
have to take that up with the people who wrote the module... >_<

Jan 4 '07 #4
In article <Nb******************@reader1.news.saunalahti.fi >,
jk******@cs.tut.fi says...
Scripsit Martin Honnen:
<script type="text/javascript">
<!--
...
//-->
</script>
- -
It is your CSS, you have a rule at line 284 in
themes/garland/style.css with selector #header-region * that sets
display: inline;
and Mozilla seems to apply that then although it does not seem to make
much sense to change such settings on script elements.

Well spotted. There's the additional problem that using <!-- and --to
"comment out" the code is simply wrong in XHTML (and hasn't been useful in
HTML either _for years_). It may _actually_ comment out the code so that the
browser won't see it at all. Of course, the markup still _validates_, since
validation does not deal with such issues.
Interesting. Can you cite some browsers that ignore scripts inside the
<!-- --comment tags in HTML?

AJ
Jan 7 '07 #5
TreeNet Webmaster wrote:
jk******@cs.tut.fi wrote:
<snip>
>... . There's the additional problem that using
<!-- and --to "comment out" the code is simply
wrong in XHTML (and hasn't been useful in HTML either
_for years_). It may _actually_ comment out the code
so that the browser won't see it at all. Of course, the
markup still _validates_, since validation does not deal
with such issues.

Interesting. Can you cite some browsers that ignore scripts
inside the <!-- --comment tags in HTML?
Strictly, inside the context of a SCRIPT element in HTML, they are not
mark-up at all, as the SCRIPT element has CDATA content.

You appear to be reading more into what was said than what was actually
written. The possibility of the - <!-- ... --- construct resulting in
any contained script being ignored only exists in XHTML, and (with the
exception of the parenthesised section) the subject of the above is
XHTML.

As XHTML is a type of XML, and XML parsers are allowed to discard
comments in XML source, it is possible that a script wrapped in that way
may never emerge from the parser. And as in XHTML the contents of a
SCRIPT element are PCDATA the wrapped script may (should) still be
interpreted as a comment and so not be presented to the javascript
parser even if they do make it through the XML parser.

I cannot say that I have tried (having long since totally abandoned the
practice of wrapping script content in mark-up comment-like constructs),
but the odds are very good that existing browsers are already ignoring
such scripts when presented with them inside genuine XHTML documents (as
opposed to the more normal (error filled and) tag-soup HTML documents
given (more or less) the illusion of its being XHTML to its authors, but
not to the browser (because of the use of text/html content type
headers, which results in the browser trying to interpret whatever it
gets as HTML)). As genuine XHTML is very rarely used, and even more
rarely scripted (certainly in a commercial context, where IE (with its
absolute inability to interpret XHTML) has to be given significant
consideration), this phenomenon can be expected to pass unnoticed by
many, and be an irrelevance to most.

In HTML the - <!-- ... --- construct wrapped around SCRIPT element
contents are just redundant, and have been so for at least half a
decade. They were introduced as a way of avoiding browser's that did not
know what a SCRIPT element was from displaying script source text to the
user. Those would be browsers pre-dating Netscape 2, and so now so old
that they are well past being of any practical concern to anyone.

Richard.
Jan 7 '07 #6
This got me a bit curious, so I put together a little test page:

http://ermarian.net/html/javascript/commented.html

The first field should always be filled when clicking the button; the
second field will only be filled if the browser doesn't throw out
commented Javascript.

In my browser (Firefox 2.0.0.1), the second field doesn't change. To be
really sure, I removed the comments and both fields were filled, so it
was really that which made the difference.

Jan 7 '07 #7
Arancaytar wrote:
This got me a bit curious, so I put together a little test page:

http://ermarian.net/html/javascript/commented.html

The first field should always be filled when clicking the button; the
second field will only be filled if the browser doesn't throw out
commented Javascript.

In my browser (Firefox 2.0.0.1), the second field doesn't change. To
be really sure, I removed the comments and both fields were filled,
so it was really that which made the difference.
For me:
Fills both fields in IE6.
Fills only the first field in Firefox 1.5.0.9, SeaMonkey 1.0.7, Opera
9.02.

--
-bts
-Motorcycles defy gravity; cars just suck
Jan 7 '07 #8
Beauregard T. Shagnasty wrote:
Arancaytar wrote:
>This got me a bit curious, so I put together a little test
page:

http://ermarian.net/html/javascript/commented.html

The first field should always be filled when clicking the
button; the second field will only be filled if the browser
doesn't throw out commented Javascript.

In my browser (Firefox 2.0.0.1), the second field doesn't
change. To be really sure, I removed the comments and both
fields were filled, so it was really that which made the
difference.

For me:
Fills both fields in IE6.
The page is served as text/html to IE so whatever happens there does not
reflect upon the handling of comment-like structures inside SCRIPT
elements in XHTML documents.
Fills only the first field in Firefox 1.5.0.9, SeaMonkey 1.0.7,
Opera 9.02.
Where the content-type header sent is application/xhtml+xml and so the
mark-up is being interpreted as XHTML.

Richard.
Jan 8 '07 #9
Richard Cornford wrote:
Beauregard T. Shagnasty wrote:
>Arancaytar wrote:
>>This got me a bit curious, so I put together a little test page:

http://ermarian.net/html/javascript/commented.html

The first field should always be filled when clicking the button;
the second field will only be filled if the browser doesn't throw
out commented Javascript.

In my browser (Firefox 2.0.0.1), the second field doesn't change.
To be really sure, I removed the comments and both fields were
filled, so it was really that which made the difference.

For me:
Fills both fields in IE6.

The page is served as text/html to IE so whatever happens there does
not reflect upon the handling of comment-like structures inside
SCRIPT elements in XHTML documents.
>Fills only the first field in Firefox 1.5.0.9, SeaMonkey 1.0.7, Opera
9.02.

Where the content-type header sent is application/xhtml+xml and so
the mark-up is being interpreted as XHTML.
Thanks. Yes, I knew that. <g Arancaytar seemed to be looking for
confirmation.

--
-bts
-Motorcycles defy gravity; cars just suck
Jan 8 '07 #10

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

Similar topics

1
by: Chris Dean | last post by:
Hi I'm useing the php NUKE CMS and am designing a theme for it. this basically consists of the the main html structure of the page being produced line by line from php echo commands I have a...
12
by: Karen Baron | last post by:
I'm attempting to login to a website and I noticed that it uses standard javascipt settings. For some reason, the code will not activate and therefore I cannot login to the website. I unblocked...
17
by: Christopher Nelson | last post by:
I have a menu tree made up of anchors inside list items in a multi-level list that includes HTML like: <ul id='xx'> <li><a href='conf.cgi' class='menu' target='main' title='Configure stuff'...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
8
by: Titatoutati | last post by:
Hi all, So, what I am trying do to is to manage some classes with javascript. It's working, but there are some things that I don't understand... Next is my sample code, and I have indicated the...
1
Atli
by: Atli | last post by:
Hi. I just installed Firefox on my shiny new Vista Ultimate, which is awesome btw :) When browsing these forums, I've noticed that Firefox shows double line breaks in code examples, something...
5
by: SM | last post by:
Hello, I have an <ul>, and when i click on a item i want to add a class to that item. The class itself will change some display properties, using CSS. See code below. But, whenever i click on a...
30
by: marijnh | last post by:
A freely-available online book about JavaScript has just been launched: http://eloquentjavascript.net It attempts to provide a comprehensive introduction to the language, and a practical...
1
by: joe | last post by:
I often would like see the HTML output produces by my Javascipt code for debugging. Is this possible?
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.