The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

##----------------------------------------------------------------------------
## HTML Object - ~/lib/HTML/Object/DOM/Element/Body.pm
## Version v0.2.0
## Copyright(c) 2022 DEGUEST Pte. Ltd.
## Author: Jacques Deguest <jack@deguest.jp>
## Created 2022/01/05
## Modified 2022/09/18
## All rights reserved
##
##
## This program is free software; you can redistribute it and/or modify it
## under the same terms as Perl itself.
##----------------------------------------------------------------------------
BEGIN
{
use strict;
use warnings;
use vars qw( $VERSION );
our $VERSION = 'v0.2.0';
};
use strict;
sub init
{
my $self = shift( @_ );
$self->{_init_strict_use_sub} = 1;
$self->SUPER::init( @_ ) || return( $self->pass_error );
$self->{tag} = 'body' if( !CORE::length( "$self->{tag}" ) );
return( $self );
}
# Note: property aLink obsolete
sub aLink { return; }
# Note: property background obsolete
sub background { return; }
# Note: property bgColor obsolete
sub bgColor { return; }
# Note: property link obsolete
sub link { return; }
sub onafterprint : lvalue { return( shift->on( 'afterprint', @_ ) ); }
sub onbeforeprint : lvalue { return( shift->on( 'beforeprint', @_ ) ); }
sub onbeforeunload : lvalue { return( shift->on( 'beforeunload', @_ ) ); }
sub onhashchange : lvalue { return( shift->on( 'hashchange', @_ ) ); }
sub onlanguagechange : lvalue { return( shift->on( 'languagechange', @_ ) ); }
sub onmessage : lvalue { return( shift->on( 'message', @_ ) ); }
sub onmessageerror : lvalue { return( shift->on( 'messageerror', @_ ) ); }
sub onoffline : lvalue { return( shift->on( 'offline', @_ ) ); }
sub ononline : lvalue { return( shift->on( 'online', @_ ) ); }
sub onpagehide : lvalue { return( shift->on( 'pagehide', @_ ) ); }
sub onpageshow : lvalue { return( shift->on( 'pageshow', @_ ) ); }
sub onpopstate : lvalue { return( shift->on( 'popstate', @_ ) ); }
sub onrejectionhandled : lvalue { return( shift->on( 'rejectionhandled', @_ ) ); }
sub onresize : lvalue { return( shift->on( 'resize', @_ ) ); }
sub onstorage : lvalue { return( shift->on( 'storage', @_ ) ); }
sub onunhandledrejection : lvalue { return( shift->on( 'unhandledrejection', @_ ) ); }
sub onunload : lvalue { return( shift->on( 'unload', @_ ) ); }
# Note: property text obsolete
sub text { return; }
# Note: property vLink obsolete
sub vLink { return; }
1;
# NOTE: POD
__END__
=encoding utf-8
=head1 NAME
HTML::Object::DOM::Element::Body - HTML Object DOM Body Class
=head1 SYNOPSIS
use HTML::Object::DOM::Element::Body;
my $body = HTML::Object::DOM::Element::Body->new ||
die( HTML::Object::DOM::Element::Body->error, "\n" );
=head1 VERSION
v0.2.0
=head1 INHERITANCE
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Body |
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+
=head1 DESCRIPTION
The L<HTML::Object::DOM::Element::Body> interface provides special properties (beyond those inherited from the regular L<HTML::Object::DOM::Element> interface) for manipulating C<<body>> elements.
=head1 PROPERTIES
Inherits properties from its parent L<HTML::Object::DOM::Element>
=head1 OBSOLETE PROPERTIES
Those properties all return C<undef>
=head2 aLink
Is a string that represents the color of active hyperlinks.
=head2 background
Is a string that represents the description of the location of the background image resource. Note that this is not an URI, though some older version of some browsers do expect it.
=head2 bgColor
Is a string that represents the background color for the document.
=head2 link
Is a string that represents the color of unvisited links.
=head2 text
Is a string that represents the foreground color of text.
=head2 vLink
Is a string that represents the color of visited links.
=head1 METHODS
Inherits methods from its parent L<HTML::Object::DOM::Element>
=head1 EVENT HANDLERS
Below are the event handlers you can use and that are implemented in this interface. However, it is up to you to fire those related events.
=head2 onafterprint
Is an event handler representing the code to be called when the afterprint event is raised.
=head2 onbeforeprint
Is an event handler representing the code to be called when the beforeprint event is raised.
=head2 onbeforeunload
Is an event handler representing the code to be called when the beforeunload event is raised.
Example:
use HTML::Object::DOM qw( window );
window->addEventListener( beforeunload => sub
{
# Cancel the event
# If you prevent default behavior in Mozilla Firefox prompt will always be shown
$e->preventDefault();
# Chrome requires returnValue to be set
$e->returnValue = '';
});
=head2 onhashchange
Is an event handler representing the code to be called when the hashchange event is raised.
=head2 onlanguagechange
Is an event handler representing the code to be called when the languagechange event is raised.
Example:
object->onlanguagechange = function;
window->onlanguagechange = sub
{
say( 'languagechange event detected!' );
};
=head2 onmessage
Is an event handler called whenever an object receives a message event.
=head2 onmessageerror
Is an event handler called whenever an object receives a messageerror event.
=head2 onoffline
Is an event handler representing the code to be called when the offline event is raised.
=head2 ononline
Is an event handler representing the code to be called when the online event is raised.
=head2 onpagehide
Is an event handler representing the code to be called when the pagehide event is raised.
=head2 onpageshow
Is an event handler representing the code to be called when the pageshow event is raised.
=head2 onpopstate
Is an event handler representing the code to be called when the popstate event is raised.
Example:
window->onpopstate = sub
{
my $event = shift( @_ );
say( "location: " . $doc->location . ", state: " . JSON->new->encode( $event->state ) );
};
$history->pushState({page => 1}, "title 1", "?page=1");
$history->pushState({page => 2}, "title 2", "?page=2");
$history->replaceState({page => 3}, "title 3", "?page=3");
$history->back(); # alerts "location: https://example.org/example.html?page=1, state => {"page" => 1}"
$history->back(); # alerts "location: https://example.org/example.html, state: null
$history->go(2); # alerts "location: https://example.org/example.html?page=3, state => {"page" =>3}
=head2 onrejectionhandled
An event handler representing the code executed when the C<rejectionhandled> event is raised, indicating that a C<Promise> was rejected and the rejection has been handled.
=head2 onresize
Is an event handler representing the code to be called when the C<resize> event is raised.
=head2 onstorage
Is an event handler representing the code to be called when the storage event is raised.
=head2 onunhandledrejection
An event handler representing the code executed when the unhandledrejection event is raised, indicating that a Promise was rejected but the rejection was not handled.
=head2 onunload
Is an event handler representing the code to be called when the unload event is raised.
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
=head1 COPYRIGHT & LICENSE
Copyright(c) 2022 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
=cut