[Typo3] Print version
Christopher
bedlamhotel at gmail.com
Sat May 21 20:56:42 CEST 2005
Hi,
On 5/20/05, racco <raczek at open.infi.pl> wrote:
> b) Using javascript to change the 'href' attribute of all the links in the
> page:
>
> <script type="text/javascript">
> function turnOffLinks() {
> alert('I am being called!');
> var linkCollection = document.getElementsByTagName('a');
>
> for (var i = 0; i < linkCollection.length; i++) {
> linkCollection[i].href = '#';
> }
> }
> </script>
>
>
> ------
>
> How should I launch this script? Because putting this in code gives nothing.
> I do not have a knowledge about JavaScript, sorry :)
>
Well, in your TS template for the PRINTABLE pages, you'll need
somthing like this:
page.bodyTag = <body onload="turnOffLInks();">
...and by the way: I threw that little script together from another
thing I was playing around with; apparently I left a totally
unnecessary 'alert('...);' in it. It should be like this:
<script type="text/javascript">
function turnOffLinks() {
// Make a list of all the <a> elements in the current document:
var linkCollection = document.getElementsByTagName('a');
// Loop through the entire list of <a> elements collected by the
previous statement:
for (var i = 0; i < linkCollection.length; i++) {
// With each <a> element, set the 'href' attribute to "#":
linkCollection[i].href = '#';
}
}
</script>
Be sure not to put the TS above into your REGULAR page object, or none
of your links will work :-)
Incidentally, you could also use the javascript DOM to strip the <a>
tags out altogether, I just opted for the quick and dirty solution. If
you want to look into that, do a Google search for something like
javascript + DOM + "change document structure"...
-Christopher
More information about the TYPO3-english
mailing list