Mozilla-Mechanize

 view release on metacpan or  search on metacpan

lib/Mozilla/Mechanize/Link.pm  view on Meta::CPAN

    my $link = $self->{link};

    my $iid = Mozilla::DOM::NSHTMLElement->GetIID;
    my $nshtmlelem = $link->QueryInterface($iid);

    return $nshtmlelem->GetInnerHTML;
}

=head2 $link->name

NAME attribute from the source tag, if any.

=cut

sub name {
    my $self = shift;
    my $link = $self->{link};

    return $link->HasAttribute('name') ? $link->GetAttribute('name') : '';
}

=head2 $link->tag

Tag name ("A", "AREA", "FRAME" or "IFRAME").

=cut

sub tag {
    my $self = shift;
    my $link = $self->{link};

    return $link->GetTagName;
}

=head2 $link->click

Click the link (does this fire onClick?).

=cut

sub click {
    my $self = shift;
    my $link = $self->{link};

    # XXX: maybe this could be done better

    # Create a click event
    my $doc = $link->GetOwnerDocument;
    my $deiid = Mozilla::DOM::DocumentEvent->GetIID();
    my $docevent = $doc->QueryInterface($deiid);
    my $event = $docevent->CreateEvent('MouseEvents');
    $event->InitEvent('click', 1, 1);

    # Dispatch the click event
    my $etiid = Mozilla::DOM::EventTarget->GetIID();
    my $target = $link->QueryInterface($etiid);
    $target->DispatchEvent($event);

    # XXX: if they didn't pass $moz to `new', they're stuck..
    my $moz = $self->{moz} || return;
    $moz->_wait_while_busy();
}


1;

__END__

=head1 COPYRIGHT AND LICENSE

Copyright 2005,2009 Scott Lanning <slanning@cpan.org>. All rights reserved.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

=cut



( run in 1.901 second using v1.01-cache-2.11-cpan-5b529ec07f3 )