InMotion Hosting Support Center
This is archived and no longer maintained. Any information contained in this article may be out of date.

In this article I'm going to discuss the process of adding a bit of JavaScript code into a PHP-Fusion article.

This process is going to take advantage of the built-in add_to_head output handling function that is available in PHP-Fusion. There are also other output handling functions like add_to_footer and add_to_meta that allow you to perform similar actions on your content. You can see the full list of PHP-Fusion functions like this that are built-in on the PHP-Fusion 8 Development & Project site.

Adding JavaScript to a PHP-Fusion article

Using the steps below, I'll walk you through the process of getting a simple JavaScript alert pop-up to function within one of your PHP-Fusion articles.

  1. Login to the PHP-Fusion admin panel.
  2. click on articlesClick on Articles.
  3. type in article content click on save articleI have gone ahead and filled in the Subject, Snippet, and the Article content with the following text:
  4. Subject JavaScript Hello!
    Snippet Make JavaScript say Hello!
    Article In PHP-Fusion we can add JavaScript to provide extra functionality to the site!

    <p style="display:none;">
    add_to_head('<script type="text/javascript">alert("Hello world!");</script>');

    You should notice that around the JavaScript code, I have added a <p style="display: none;"> style to the paragraph tag to completely hide the JavaScipt code. Without this, the JavaScript code would still run on the page, however you'd still see the text add_to_head('') displayed in the article.

    Now when we access the article that we added this JavaScript code to, we successfully see that the JavaScript code is run in our web-browser, and a pop-up message is displayed with our text.

    javascript pop up displayed

You should now know how you can get JavaScript code successfully added to one of your PHP-Fusion articles.

You are viewing Section 1: How to insert JavaScript into a PHP-Fusion article
Section 2: Using the Contact Form in PHP-Fusion

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!