Digg icon reddit icon Stumbleupon icon
Print Email     Print Edition Stories

Tech News Headlines Widget BETA Documentation

The Mass High Tech News Headlines Widget provides a quick and easy way to incorporate the most recent headlines from any of Mass High Tech’s many RSS feeds into your site. Through some basic configuration functions, the widget can be customized to adapt to your site’s look and feel.

Table of Contents

Full Installation Instructions:

Quick Start Installation

To quickly install the widget on your website without any customization, copy the code below and paste it where you want the widget to appear:

HTML version

<script type="text/javascript" src="http://www.masshightech.com/tech-news-widget/widget.js"></script>
<script type="text/javascript">
    var widget = new MHTWidget();
    widget.place();
</script>

XHTML version

<script type="text/javascript" src="http://www.masshightech.com/tech-news-widget/widget.js"></script>
<script type="text/javascript">
//<![CDATA[
    var widget = new MHTWidget();
    widget.place();
//]]>
</script>

Step-By-Step Guide to Installing the Widget

  1. Include the widget JavaScript file.
    Add a line of HTML to import the code needed to display the widget.
  2. Load and customize the widget using the provided configuration methods.
    Optionally change a number of widget display settings, including the widget text color, link color, maximum number of articles to display, whether to load links clicked in the current window or use a pop-up and more.
  3. Place the widget onto the page.
    With a simple method call, place the widget onto the website.

Include the Widget Code

Use the following code to include the needed widget code onto the webpage that will be displaying it:

<script type="text/javascript" src="http://www.masshightech.com/tech-news-widget/widget.js"></script>

This line can be placed in the <head> tag, or wherever else website JavaScript file-includes are placed.

Note: this script tag must be called on the page before you attempt to load the widget.

Load the Widget

Create a new, empty <script> tag. This will be where the widget is loaded, customized and eventually placed. Load the widget in these new tags. There are two different examples provided, one as an HTML-valid solution and the other as an XHTML-valid solution. Use the appropriate version based on the webpage’s DOCTYPE.

HTML version
<script type="text/javascript">
    var widget = new MHTWidget();
</script>
XHTML version
<script type="text/javascript">
//<![CDATA[
    var widget = new MHTWidget();
//]]>
</script>

Customize & Configure the Widget

The widget comes pre-defined with a set of values that matches the Mass High Tech branding. Customization is not required, but has been provided so that the widget can match the look and feel of the page into which it is placed. This customization and configuration is accomplished by calling a set of methods provided to set certain aspects of the widget’s styling.

Note: Code written in the previous step has been ghosted to focus on the new additions.

HTML version
<script type="text/javascript">
    var widget = new MHTWidget();
    widget.setBoxWidth('300px');
    widget.setTextColor('#999');
    widget.setArticleLimit(7);
</script>
XHTML version
<script type="text/javascript">
//<![CDATA[
    var widget = new MHTWidget();
    widget.setBoxWidth('300px');
    widget.setTextColor('#999');
    widget.setArticleLimit(7);
//]]>
</script>

This sample configuration will display a 300-pixel wide widget, whose text color is a medium gray. It will display up to seven most recent articles.

Customization Reference Guide

The following guide is a list of all options that can be set in the widget. These options can be set in any order, and any number of them can be added or excluded from configuration. Each value set must be a string (text surrounded by quotes) unless otherwise noted in the second column.

Function Description Default Value
setFeed(feedName); Selects the Mass High Tech RSS feed to load.
Valid feedName options:
  • mass_high_tech (Mass High Tech news)
  • storage
  • nanotechnology
  • personnel
  • robotics
  • defense
  • education_and_training
  • startups
  • legislation
  • entrepreneurship
  • information_technology
  • instrumentation
  • financial_services
  • services
  • envirotech
  • energy
  • life_sciences
  • networks
  • manufacturing
  • real_estate
  • internet
  • software
  • hardware
'mass_high_tech'
setBoxWidth(width); Sets the width of box into which the widget will be placed. This value should be in either px, em, or %. '250px'
setTextColor(color); Sets the color of the widget’s non-link text. This value should be a hexadecimal value (including the starting #). '#000000'
setLinkColor(color); Sets the color of the widget’s linked text. This value should be a hexadecimal value (including the starting #). '#0072bc'
setBackgroundColor(color); Sets the background-color of the widget. This value should be a hexadecimal value (including the starting #). '#f7f5e9'
setBorderColor(color); Sets the border-color of the widget’s bounding box. This value should be a hexadecimal value (including the starting #). '#cfcba9'
setBorderSize(size); Sets the size of widget’s bounding box. This value should be in either px, em, or %. '2px'
setArticleLimit(limit); Sets the maximum number of articles the widget will display. The widget will only display fewer if fewer are available from Mass High Tech. Value must be at least 1 and no greater than 10. Value should be an integer. 4
setNewWindowFlag(flag); If set to true, all links clicked will pop open in a new window. If set to false, all links clicked will open in the current window. Value should be a boolean. false

Place the Widget

After the widget has been loaded and configured, call the method place() to place the widget on your page. The widget will be placed into the code wherever this function has been called.

HTML version
<script type="text/javascript">
    var widget = new MHTWidget();
    widget.setBoxWidth('300px');
    widget.setTextColor('#999');
    widget.setArticleLimit(7);
    widget.place();
</script>
XHTML version
<script type="text/javascript">
//<![CDATA[
    var widget = new MHTWidget();
    widget.setBoxWidth('300px');
    widget.setTextColor('#999');
    widget.setArticleLimit(7);
    widget.place();
//]]>
</script>

Advanced Styling

The widget placed is wrapped in a <div> with an id of MHTWidget. This will allow you to do some additional styling through your CSS. Advanced styling is not recommended, but is possible.

Debugging

The Mass High Tech widget will throw exceptions if something goes wrong. If the widget doesn’t appear to be working, wrapping your widget code in a try/catch block may be helpful. For example:

HTML version
<script type="text/javascript">
    try {
        var widget = new MHTWidget();
        widget.setBoxWidth('300px');
        widget.setTextColor('#999');
        widget.setArticleLimit(7);
        widget.place();
    } catch (e) {
        alert(e.message);
    }
</script>
XHTML version
<script type="text/javascript">
//<![CDATA[
    try {
        var widget = new MHTWidget();
        widget.setBoxWidth('300px');
        widget.setTextColor('#999');
        widget.setArticleLimit(7);
        widget.place();
    } catch (e) {
        alert(e.message);
    }
//<![CDATA[
</script>

Some browsers allow you to print message to the browser’s console. If your browser supports this, you can replace alert(e.message); in the above examples with console.log(e.message);. Using console.log technique can work better than alert, as it doesn’t pause the script from continuing since no dialog boxes will pop-up.

It’s also worth noting that there are known cases in which some versions of Internet Explorer will kill the script if console.log(); is used.

Troubleshooting

Nothing shows up when I place the widget.
The widget will attempt to use your version of jQuery if it is already found loaded on the page. However, the Mass High Tech RSS Widget requires jQuery version 1.2 or higher. If the version included on the page is earlier than this, the widget will not load. If you are not using jQuery on your page, the widget will take care of that by itself.
I think the widget is conflicting with my JavaScript framework.
The widget uses jQuery to streamline its remote-RSS call, however this code is written directly off the jQuery variable, a no-conflict method which should not interfere with any pre-existing JavaScript framework.
I’m trying to custom-style the widget, but it’s just not working.
Not every aspect of the widget can be customized. See the Advanced Styling section for more information on how custom styling works.

Widget Support

Having issues or have questions about the widget? Please contact mlang@masshightech.com.

Most Popular Stories
EmailedViewed
Stay Informed
Check which newsletter you'd like to receive.
TechFlash (Daily)
BioFlash (Daily)
GreenFlash (Weekly)
Startup Report (Weekly)
Breaking news, MHT events, local announcements
RSS feeds
Your email:

Affiliate publications: ACBJ.com, Boston Business Journal, Bizjournals.com, Portfolio.com, Wired.com

Web Site Developed by Neptune Web, Inc.

Use of and/or registration on any portion of this site constitutes acceptance of our User Agreement and Privacy Policy. About our ads.