The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Rose::HTML::Script - Object representation of the "script" HTML tag.

SYNOPSIS

    $script = Rose::HTML::Script->new(src => '/main.js');

    print $script->html;

    $script = 
      Rose::HTML::Script->new(
        script => 'function addThese(a, b) { return a + b }');

    print $script->html;

    ...

DESCRIPTION

Rose::HTML::Script is an object representation of a "script" HTML tag used to reference or wrap scripts (e.g., JavaScript).

This class inherits from, and follows the conventions of, Rose::HTML::Object. Inherited methods that are not overridden will not be documented a second time here. See the Rose::HTML::Object documentation for more information.

HTML ATTRIBUTES

Valid attributes:

    charset
    class
    defer
    dir
    id
    lang
    onclick
    ondblclick
    onkeydown
    onkeypress
    onkeyup
    onmousedown
    onmousemove
    onmouseout
    onmouseover
    onmouseup
    src
    style
    title
    type
    xml:lang

Required attributes (default values in parentheses):

    type (text/javascript)

Boolean attributes:

    defer

CONSTRUCTOR

new PARAMS

Constructs a new Rose::HTML::Script object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name.

CLASS METHODS

default_support_older_browsers [BOOL]

Get or set a boolean value that indicates whether or not the XHTML produced by objects of this class will, by default, attempt to support older web browsers that have trouble parsing the comments used to wrap script contents. The default value is true. See the support_older_browsers object method for some examples.

OBJECT METHODS

contents [TEXT]

Get or set the contents of the script tag.

script [TEXT]

This is an alias for the contents method.

src [URI]

Get or set the URI of the script file. If this attribute is set, then the contents of of the script tag are ignored when it comes time to produce the HTML.

support_older_browsers [BOOL]

Get or set a boolean value that indicates whether or not the XHTML produced by this object will attempt to support older web browsers that have trouble parsing the comments used to wrap script contents. If undefined, the value of this attribute is set to the return value of the default_support_older_browsers class method.

Examples:

    $script = 
      Rose::HTML::Script->new(script => 'function foo() { return 123; }');

    print $script->xhtml;

This prints the following big mess which helps older browsers while also remaining valid XHTML.

    <script type="text/javascript"><!--//--><![CDATA[//><!--
    function foo() { return 123; }
    //--><!]]></script>

Now the other mode:

    $script->support_older_browsers(0);
    print $script->xhtml;

which prints:

    <script type="text/javascript">
    //<![CDATA[
    function foo() { return 123; }
    //]]>
    </script>

See http://hixie.ch/advocacy/xhtml for more information on this topic.

AUTHOR

John C. Siracusa (siracusa@gmail.com)

COPYRIGHT

Copyright (c) 2007 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.