Slain wrote :
Quote:
I have a big list of HTML files, which need to be updated with a
common text.
>
>
<script language=JavaScript
src="./highlight.js"></script>
>
First language is deprecated; type is the normal replacement and it is
both backward and forward-compatible.
Quote:
I need to add the above line in each of the html files, before the
text "<\head>".
It's </head>.
Just use an advanced text editor to do that. It's simple to do.
Free software (libre/open-source) text editors:
http://en.wikipedia.org/wiki/List_of...open-source.29 Quote:
All the HTML files have this text and I think some
kind of search on this string and either replacing "</head>" with the
text above and appending "<\headto it, might be one way to do it or
just find the <\headpart and insert the text before that.
>
>
>
On similar lines, the text below goes towards the end. The problem is
similar to the above one and I think all that needs to be done, is
read the text below from a file, do a similar search for some text
below which this insert part should go and put it there.
>
>
<p><script type="text/javascript">var mailSubject = 'Hardware
Overview';
var mailBody = 'Your Technical Support Team hopes this topic will
be helpful: ' + location.href;
var mailDisplay = 'Click here to email this topic.';
document.write(
'<a href="mailto:YourName@YourAddress.com'
+ '?subject=' + escape(mailSubject)
+ '&body=' + escape(mailBody)
+ '">' + mailDisplay + '</a>'
);</script></p>
You're overreaching here in my opinion. And your code has problems.
First, you must escape the ampersand with &
Second, you are adding a closing </ptag when there is not a start <p>.
Third, you'll need to escape the closing tags inside the document.write
block:
Common HTML Validation Problems
Writing HTML in a SCRIPT element
http://www.htmlhelp.com/tools/valida...html.en#script
HTML 4, Section 18.2.4 Dynamic modification of documents
http://www.w3.org/TR/html4/interact/....html#h-18.2.4
HTML 4, Appendix B.3.2 Specifying non-HTML data, Element Content
http://www.w3.org/TR/html4/appendix/...html#h-B.3.2.1
"When script or style data is the content of an element (SCRIPT and
STYLE), the data begins immediately after the element start tag and ends
at the first ETAGO ("</") delimiter followed by a name start character
([a-zA-Z]); note that this may not be the element's end tag. Authors
should therefore escape "</" within the content."
Quote:
<script type="text/javascript"
language=JavaScript1.2><!--
As mentioned already, language attribute is deprecated.
Don't use HTML comments as they are unneeded, unnecessary and
potentially harmful.
Don't Use HTML Comments In Script Blocks
http://www.javascripttoolbox.com/bes...ices/#comments Quote:
beginSearch ();
//--></script>
Quote:
>
>
Any ideas would be helpful.
Validate your markup code! Preferably with/for a strict DTD.
http://validator.w3.org/
Gérard
--
Using Web Standards in your Web Pages (Updated Apr. 2007)
http://developer.mozilla.org/en/docs...your_Web_Pages