Can anyone help me to find which action and how that is used to display an alert message while load the web page in WordPress.
Is it possible to use wp_head
action? How would I do that?
Can anyone help me to find which action and how that is used to display an alert message while load the web page in WordPress.
Is it possible to use wp_head
action? How would I do that?
Yes you can use
wp_head
hook to output custom style and js in WordPress<head>
tag.
Try this,
function your_function()
{
?>
<script type="text/javascript">
function codeAddress() {
alert('ok');
}
window.onload = codeAddress;
</script>
<?php
}
add_action('wp_head', 'your_function');
This code is tested and is fully functional.
Code goes in function.php file of your active child theme (or theme). Or also in any plugin php files.
Reference: run function when page is loaded