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>');
    </p>

    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.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

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

News / Announcements

WordPress wp-login.php brute force attack
Updated 2014-07-17 06:43 pm EST
Hits: 200965

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

Need more Help?

Search

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: support@InMotionHosting.com
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!