How do I add my hello word javascript to my template file
-
Hi,
I am trying to add javascript helloworld to my template file. I have added the following code to my header.php file:‘<?php
function my_script_load() {
wp_register_script(‘sitescript’, get_bloginfo(‘template_directory’).’/js/webcam.js’, array(), false);
wp_enqueue_script(‘sitescript’);
}
?>
<?php
if( is_page(‘webcam’)) {
add_action(‘init’, ‘my_script_load’);
}
?><?php wp_head(); ?>’
where webcam is my template file name for webcam.php.
The javascript inside of the webcam.js file is:
‘<script type=”text/javascript”>
alert(‘Hello, World!’);
</script>’I can’t tell way it’s not loading. Any help would be much appreciated. Thanks, Margaret
- The topic ‘How do I add my hello word javascript to my template file’ is closed to new replies.