Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Using CGI's start_html to add attributes to <body>

by kejohm (Hermit)
on Jul 22, 2011 at 06:04 UTC ( #916056=note: print w/replies, xml ) Need Help??

in reply to Using CGI's start_html to add attributes to <body>

Use the -onLoad parameter for start_html(), eg.

start_html(-onLoad => "javascript:JSname();");

Check out the docs for more details.

Replies are listed 'Best First'.
Re^2: Using CGI's start_html to add attributes to <body>
by afoken (Abbot) on Jul 22, 2011 at 12:45 UTC

    The javascript: label inside the event handler is cargo cult nonsense, drop it.

    The only place where the javascript: prefix once made sense was in the href attribute of an a element (i.e. <a href="javascript:foo()">...</a>), where it was interpreted as a pseudo-protocol. This was needed for Netscape Navigator < 2.0, Internet Explorer < 3.0, Opera < 5.12, and other long forgotten software from the dawn of the WWW decades ago, lacking the standard onclick event handler.

    For modern web pages, don't insert any Javascript at all into the HTML document, load it from an external resource and use DOM methods to add event handlers. Libraries like jQuery make this much easier than coding everything manually.


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://916056]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2018-07-16 20:35 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (349 votes). Check out past polls.