Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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.

Comment on Re: Using CGI's start_html to add attributes to <body>
Select or Download Code
Replies are listed 'Best First'.
Re^2: Using CGI's start_html to add attributes to <body>
by afoken (Monsignor) 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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2016-05-28 13:26 GMT
Find Nodes?
    Voting Booth?