Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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
Re^2: Using CGI's start_html to add attributes to <body>
by afoken (Parson) 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.

    Alexander

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://916056]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2014-08-29 20:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (288 votes), past polls