Using Web Page User Web Page HTML Creation: Web Server Function Application Guide
Using Web Page User Web Page HTML Creation: Web Server Function Application Guide
Programmable Controller
MELSEC iQ-F Series
</br>
<head>
TAG
CSS
HTML
INTRODUCTION
Thank you for purchasing the MELSEC iQ-F Series.
This guide describes the settings related to the Web server function of the FX5 CPU module.
It should be read and understood before attempting to install or use the module.
• This product has been manufactured as a general-purpose part for general industries, and has not been designed or
manufactured to be incorporated in a device or system used for purposes related to human life.
• Before using the product for special purposes such as nuclear power, electric power, aerospace, medicine, or passenger
movement vehicles, consult Mitsubishi Electric representative.
• This product has been manufactured under strict quality control. However, when installing the product where major accidents
or losses could occur if the product fails, install appropriate backup or failsafe functions in the system.
Note
• If in doubt at any stage during the installation of the product, always consult a professional electrical engineer who is qualified
and trained in the local and national standards. If in doubt about the operation or use, please consult the nearest Mitsubishi
Electric representative.
• Mitsubishi Electric will not accept responsibility for actual use of the product based on these illustrative examples.
• This guide content, specification, etc., may be changed, without a notice, for improvement.
• The information in this guide has been carefully checked and is believed to be accurate; however, if you notice a doubtful point,
an error, etc., please contact the nearest Mitsubishi Electric representative. When doing so, please provide the document
number given at the end of this guide.
2
TABLE OF CONTENTS
INTRODUCTION ...................................................................................................................................................................... 2
RELEVANT CATALOGS/MANUALS ......................................................................................................................................... 4
PRECAUTIONS ........................................................................................................................................................................ 5
LIMITATIONS ........................................................................................................................................................................... 5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS) 75
5.1 What Is JavaScript (JS)? ...............................................................................................................................................75
5.2 Common Items ..............................................................................................................................................................77
5.3 Table ................................................................................................................................................................................81
5.4 Graphs ............................................................................................................................................................................87
5.5 Image/Figure ..................................................................................................................................................................98
5.6 Operation Buttons .......................................................................................................................................................107
7. REFERENCES 132
7.1 Style Sheet References ..............................................................................................................................................132
7.2 HTML Tag References .................................................................................................................................................137
7.3 Color Name/Color Code ..............................................................................................................................................143
3
RELEVANT CATALOGS/MANUALS
u Configuration of catalogs and manuals
The following catalogs and manuals should be referred to before using the Web pages.
When using the system Web pages Web Server Function Application Guide
Using Web Page
Startup and Introduction
When using the user Web pages Web Server Function Application Guide
Using Web Page
User Web Page HTML Creation
u Relevant catalogs/manuals
For the detailed specifications, precautions, and limitations of the product, refer to the following catalogs or manuals.
e-Manual refers to the Mitsubishi Electric’s FA electronic book manuals that can be browsed using a dedicated tool.
e-Manual has the following features:
Point
• Required information can be cross-searched in multiple manuals. (Cross Document Search)
• Pages that users often browse can be bookmarked.
4
PRECAUTIONS
Illegal access from external devices
Incorporate other measures if the safety of the programmable controller system must be maintained against illegal access
from an external device. Mitsubishi shall not be held liable for any system problems that may occur due to illegal access. The
user authentication of the Web server function is one of the methods for preventing illegal access (such as program or data
destruction) from an external device. It does not completely prevent illegal access.
Examples of measures against illegal access are given below.
• Install a firewall.
• Install a personal computer as a relay station, and control the relaying of sent/received data with an application program.
• Install an external device for which the access rights can be controlled as a relay station (contact the network provider or
equipment dealer for details on the external devices for which access rights can be controlled).
Firewall functions
• Filtering function
This function intercepts illegal packets and passes permitted
Firewall
packets only.
LIMITATIONS
Response performance of Web pages
The response performance of Web pages varies according to the following causes.
The response performance may degrade due to the network line status or the communication status of the Ethernet function of
the FX5 CPU.
• Load factor of an Ethernet line (line congestion)
• Number of connections that are used simultaneously (refreshing other connections)
• Communication load status including the communication functions other than the Web server function set using the Ethernet
function of the FX5 CPU
• Large scan time of the FX5 CPU when Web page update is requested
Since the communication timeout time depends on the browser specifications, it may not be the same as the timeout time of the
Web server (five minutes). The design of the error window differs depending on the browser.
Special Note For the precautions and limitations, refer also to “FX5 User’s Manual (Ethernet Communication) [JY997D56201]”.
5
1
1. BASICS OF CREATING HTML <TAGS>
BASICS OF CREATING HTML < TAGS >
About HTML HTML Structure Basic Rules About Tags Tag Types Naming Files
What Is HTML?
HTML is an abbreviation for “Hyper Text Markup Language”. It is a language developed for creating Web pages. A great number
of Web pages currently accessible on the Internet have been created with HTML and can be viewed with Web browsers (such as
Internet Explorer® and Google Chrome®).
A Web browser reads HTML files and image files, organizes the contents into an easily readable form, and displays them as a Web
2 page.
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
The source of the HTML file of the Mitsubishi Electric site can be displayed
in Internet Explorer® with the following procedure.
Methods for displaying the source (operation example using Internet Explorer®)
Right-click the Internet Explorer® window and select [View Source].
Any of the methods listed on the left will display the
Select [View] - [Source] on the toolbar.
source at the bottom of the Web browser window.
Press the [F12] key.
Mitsubishi Electric site The screen shows a display example when Internet Explorer® is used.
3
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
4 Source display
of HTML file
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
HTML rules consist of a simple structure and character strings. HTML can be created easily.
6
1
1. BASICS OF CREATING HTML <TAGS>
Creating a Web page requires a language for writing the Web page, and there are various languages other than HTML such as
XHM, SGML, and XHTML.
The figure below illustrates the basic structure of HTML and the meaning of each area.
Area that declares the HTML version and that the document
2
Declaration area (start)
Area for information related to the Web page such as the title
Information area and character code
Area that specifies the text, images, and other such items to be
Body area displayed in Web browsers
Declaration area (end) Area that indicates the end of the HTML 3
Notepad
<!DOCTYPE html>
Declaration area (start)
<html lang="en">
<head>
4
<meta charset="UTF-8">
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
Information area
<title>Web Server Page</title>
</head>
<body>
</body>
7
1
1. BASICS OF CREATING HTML <TAGS>
BASICS OF CREATING HTML < TAGS >
About HTML HTML Structure Basic Rules About Tags Tag Types Naming Files
An HTML document consists of many elements. The following table lists some basic elements.
DOCTYPE declaration
<!DOCTYPE html> This tag is written at the beginning of an HTML document to declare the version of HTML.
<!DOCTYPE html> means that “This HTML is written in HTML5”.
html element
2 <html>: Start tag
</html>: End tag This tag pair indicates that the language of this document is HTML.
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
All elements should be written within the range between <html> and </html>.
head element
<head>: Start tag
</head>: End tag The information about the entire document, such as meta information and title information, is written
within the range between <head> and </head>.
meta element
<meta> Meta information (meta data) means “the information about information”. This tag indicates the
information about this HTML document. <meta charset="UTF-8"> means that “This HTML document is
written with the character code UTF-8”.
3 body element
<body>: Start tag
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
</body>: End tag This tag pair specifies the text, images, and tables to be displayed on the Web page.
Only the contents within the range between <body> and </body> are displayed on the Web page.
The characters used for HTML tags are not case-sensitive, so <html> and <HTML> mean the same. In this guide, tags are written
in lowercase.
<body> <BODY>
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
8
1
1. BASICS OF CREATING HTML <TAGS>
In HTML, all information is written with “tags”. There are tags specified for a wide variety of items including paragraphs, line
breaks, and images.
This section explains the basic way of using tags.
What is a tag?
A tag is a symbol or a mark such as <html> or <head> that is used for creating HTML. The way to use tags is determined by the
2
rules of HTML. A document that is written according to the rules of HTML is called an “HTML document”. HTML is provided in
Structure of tags
Tags can broadly be separated into the two types shown below.
It is also possible to create a layered structure by writing tags within the contents of other tags. Note that although HTML is basically
written as a layered structure of tags, the deeper the layers, the more difficult the document is to read. 3
Notepad
<html lang="ja">
<head>
<meta charset="UTF-8">
Range of the head tags
<title>Web Server Page</title> Range of the title tags
</head>
<body>
Images and document contents Range of the body tags 4
</body>
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
An “element” refers to the entire content enclosed by the start tag and end tag.
Element
Single-byte spaces after the start tag and before the end tag are ignored. Also, two or more consecutive single-
Point byte spaces within the tag contents are handled as if they were just one single-byte space.
9
1
1. BASICS OF CREATING HTML <TAGS>
BASICS OF CREATING HTML < TAGS >
About HTML HTML Structure Basic Rules About Tags Tag Types Naming Files
This section introduces tags that are commonly used with HTML.
Web page
<header> Writes the contents that are displayed at the
header Page title and similar contents
Header top of the Web page.
2
<footer> Writes the contents that are displayed at the
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
Footer bottom of the Web page. footer Copyright display and similar contents
The <h1> to <h6> tags are used to write the document headings. The larger the number in the tag, the smaller
the font size of the heading.
The <p> to </p> tags are used to write a paragraph in the document.
Long sentences automatically breaks at the right edge of the display area, but this tag can be used to insert a
line break at the specified location.
4
HTML document Web browser display
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
The line break position can be specified as The line break position can be specified as
<br>
desired with the <br> tag. desired with the
Line break tag.
Line breaks within an HTML file are ignored. For an easy-to-understand display, use the <p> and <br> tags
Point effectively.
10
1
1. BASICS OF CREATING HTML <TAGS>
Use the <table> tag to create a table. Use the <tr> and <td> tags to write the elements in the table, as shown in
the following example. For tag details, refer to Table in 7.2 HTML Tag References.
<table>
<tr>
<table>
<td>Apple 1</td><td>Apple 2</td> <td> </td> <td> </td>
Table
</tr> <tr> Apple 1 Apple 2 </tr>
<td>Orange 1</td><td>Orange 2</td> <tr> Orange 1 Orange 2 </tr> 2
</tr>
Other tags
To display an image, use the <img> tag to specify the image file. Commonly used image file formats are PNG,
JPEG, and GIF. (PNG is the recommended file format.)
Syntax: <a href="link destination URL">text to click to jump to the link destination</a>
<a>
HTML document Web browser display
Anchor
(for <a href="2.html">Next</a> 1 2
jumping
<a href="1.html">Back</a>
to a link Next Back
destination)
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
11
1
1. BASICS OF CREATING HTML <TAGS>
BASICS OF CREATING HTML < TAGS >
About HTML HTML Structure Basic Rules About Tags Tag Types Naming Files
Type Character
Single-byte alphabet abcdefghijklmnopqrstuvwxyz
Naming Files
The name of the HTML file that is used as the top page of user Web pages must be “index.html”. The HTML files used for other
pages can be named as desired.
men u. html
Ex.
Name Extension
setting specifications.
http://192.168.1.10 File
Title
Edit View Favorites Tools Help
Use easy-to-understand file names that match the display contents. Complicated file names and serial numbers
Point can be easily mistaken when entering URLs directly or setting links.
12
1
2. CREATING AND DISPLAYING SIMPLE HTML DOCUMENTS ON A PERSONAL COMPUTER
Use Notepad in Windows® to create an HTML file and display it in a Web browser (Internet Explorer®).
Moreover, learn the method of using a Web browser to check the HTML (source) of the displayed Web page.
2.1 Preparation
Prepare a personal computer running Windows® that complies with the following specifications.
Microsoft® Windows® 10
Personal computer
running Windows®
Microsoft® Windows® 8 2
Microsoft® Windows® 7
This section uses an example in Windows® 10 to describe the procedure of using Notepad, which is included in Windows® as
standard, to actually create an HTML file and display it in a Web browser.
Notepad window
13
1
2. CREATING AND DISPLAYING SIMPLE HTML DOCUMENTS ON A PERSONAL COMPUTER
BASICS OF CREATING HTML < TAGS >
Preparation HTML File Creation Web Browser Display HTML Source Display
HTML is composed entirely of text, so Web pages can be created and edited through the use of a general-purpose text editor.
</head>
<body>
<p><u>XX Manufacturing Equipment XX Process</u></p>
<p>Production Status</p>
</body>
</html>
[Toolbar: File]
Click [Save As].
<!DOCTYPE html>
3 <html>
<head>
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
index . html
File name Extension
14
1
2. CREATING AND DISPLAYING SIMPLE HTML DOCUMENTS ON A PERSONAL COMPUTER
15
1
2. CREATING AND DISPLAYING SIMPLE HTML DOCUMENTS ON A PERSONAL COMPUTER
BASICS OF CREATING HTML < TAGS >
Preparation HTML File Creation Web Browser Display HTML Source Display
Use one of the following methods to display the line numbers and HTML document at the bottom of the Web browser window.
• Right-click the Internet Explorer® window and select [View Source].
• Select [View] - [Source] on the toolbar.
• Press the [F12] key.
2
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
3
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
16
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
This chapter describes how to create a user Web page by using HTML files (the Web server function library) that can be obtained
from the Mitsubishi Electric representative.
2
3.1 Before Starting
3.2 Preparation
3.3 Reuse
4
Device monitor page creation
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
3.6 Troubleshooting
17
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
In this chapter, the JavaScript and CGI objects that can be used with user Web pages are used to create an HTML page like that
shown below.
For details on and to change JavaScript and CGI objects, refer to their chapters.
• JavaScript details 5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
Related Page
• CGI details 6. CREATING A DEVICE MONITOR WINDOW WITH CGI
2
uMenu: Page switching uLevel display: Pressure status display
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
Refer to 3.4 User Web Page Creation Refer to 3.4 User Web Page Creation
- Menu page creation. - Pressure meter page creation.
3. Device Monitor
3 Menu
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
Reuse the CGI example in chapter 6 to create the Reuse the user Web page library to create the
component. component.
Refer to 3.4 User Web Page Creation Refer to 3.4 User Web Page Creation
- Device monitor page creation. - Temperature change page creation.
Read
Menu Menu
18
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
3.2 Preparation
Relevant • Web Server Function Application Guide Using Web Page Startup and Introduction
documents [manual number: L(NA)08643ENG]
Related page • 6. USING USER WEB PAGE
Obtain the user Web page library from the Mitsubishi Electric representative. 2
Decompress the obtained file.
Check that the structure of the obtained files and folders is as shown below.
css UserWebStyle.css
img sample0.png
sample2.png
19
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
level.html
2
Historical graph Web page
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
historical.html
log-in_User.html
JavaScript
Style Sheet
3 css UserWebStyle.css
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
button-menu.css
Reuse index.html (an HTML file obtained from the Mitsubishi Electric representative) to create the level display Web page (level.
4 html) and the historical graph Web page (historical.html). For the reuse method, refer to 3.3 Reuse.
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
123 22500
Menu Menu
The following image files in the img folder are not used in this guide. Please remove them.
20
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
3.3 Reuse
“index.html” overview
The relationships between and the display objects of the files contained in the User Web page library are shown in the following
figure.
uFile correlations
2
The JavaScript parameter setting objects and image files written in white on a gray background are not used in the creation
HTML file
index.html
Declaration area
JavaScript
FUserWebLib.js
JavaScript parameter settings
Declarations (end)
21
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
The user Web page library HTML document (index.html) that is reused when creating the level display Web page (level.html) and
the historical graph Web page (historical.html) is shown below.
1 <!DOCTYPE html>
2 <html xmlns="http://www.w3.org/1999/xhtml">
2 3 <head>
4 <!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
5 <meta charset="UTF-8">
6 <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
7 <!-- Set the title. -->
8 <title>Sample</title>
9 <link href="./css/UserWebStyle.css" rel="stylesheet" media="all" />
10 <!-- Reading the library JavaScript (Change the path to match the storage location.) -->
11 <script src="./FUserWebLib.js"></script>
12 <!-- Write the proprietary JavaScript from this point. -->
13 <!-- Write the user JavaScript here. -->
14 <script>
15 var updateInterval = 5;
16 var dspLanguage = 'en-US';
17
18 // Data Block object
19 temp = [];
3 20 for(var i = 0; i < 8; i++){
21 temp.push({
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
22 dsp: 'X' + i,
23 name: 'X' + i,
24 base: 'B',
25 format: 6
26
27 });
28 }
29 for(var i = 0; i < 8; i++){
30 temp.push({
31 dsp: 'Y' + i,
32 name: 'Y' + i,
33 base: 'B',
34 format: 6
35
36 });
4 37 }
dataBlockParam = {
38
dev: temp,
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
39
40 direction: 1,
41 blkSize: 8,
42 devNamDisp: 1,
43 devNamCol: 'white',
44 devNamBkCol: '#808080',
45 devNamWidth: 100,
46 devNamHeight: 40,
47 devValCol: 'blue',
48 devValBkCol: 'white',
49 devValWidth: 80,
50 devValHeight: 50,
51 lnCol: 'blue',
52 xPos: 20,
53 yPos: 40
54 }
55 WSDatblk(dataBlockParam);
56
22
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
100
23
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
127
128 // Write button object
129 WSWrtBtn({
130 devName: 'X0',
131 devBase: 'B',
132 devFormat: 6,
133
134 wrVal: '1',
135 wrBtn: 'write_btn',
136 btnTxt: 'OK',
137 btnWidth: 150,
138 btnHeigh: 50,
139 wrComfirm: 1,
140 language: 1,
141 xPos: 700,
4 142 yPos: 40,
143 });
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
144
145 // Write button object
146 WSWrtBtn({
147 devName: 'X0',
148 devBase: 'B',
149 devFormat: 6,
150
151 wrVal: '0',
152 wrBtn: 'write_btn',
153 btnTxt: 'NG',
154 btnWidth: 150,
155 btnHeigh: 50,
156 wrComfirm: 1,
157 language: 1,
158 xPos: 700,
159 yPos: 130,
160 });
161
24
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
25
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
An image and buttons for switching the Web page are displayed on the page created with this example. Use a Style Sheet to
design the buttons for switching the Web page.
2
uSpecifications
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
[Design example]
1. Pressure Meter
Web page switching
2. Temperature Change Graph button display Link destination
• Design (Style Sheet) • level.html
• Page switching • historical.html
3. Device Monitor
• device.html
3
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
uFunctions to use
Reference
Function Creation method Example/special note
section
Background color Style Sheet Write a Style Sheet inside the HTML file. 7.1
Use an HTML tag to display the image.
Image display <img> tag
<img src="image file name" alt="alternatively displayed text">
Font size <h3></h3> tags <h3>Heading 3</h3> 7.2
Text display Underline <u></u> tags <u>Text in this range is underlined.</u>
Paragraph <p></p> tags Use <p></p> to indicate paragraphs and insert line breaks.
When the button is clicked, its display changes to that shown
on the right.
Design Style Sheet
Web page Text Text
switching button
Before being clicked After being clicked 7.1
4 display
(menu selection) Page switching <a></a> tags <a href="link destination URL">Displayed text</a>
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
uFiles to create
File type File name Remarks
The file name of the initial user Web server page that is displayed
HTML index.html
is “index.html”. Do not change this name.
This file can be named as desired. If you change it, also change the file name
Image companylogo.png
of the image files in the <img> tags in the link settings of the HTML file.
This file can be named as desired. If you change it, also change the file name
Style Sheet button-menu.css of the Style Sheet file in the link settings of the HTML file.
26
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
uCreation procedure
[HTML]
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- Set the title. -->
<title>Menu</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<!-- Link settings of the Style Sheet file for the design of the Web page switching buttons -->
<link href="./css/button-menu.css" rel="stylesheet" media="all"/>
<!-- Web page background color setting (Create a Style Sheet inside the HTML file.) -->
<style> 3
body {
background-color: #c0c0c0;
<!-- For centering the Web page switching buttons (Create a Style Sheet inside the HTML file.) -->
<style type="text/css">
<!--
.web-center {
text-align:center; /* Internet Explorer centering */
margin-left:auto; /* Centering for Web browsers other than Internet Explorer */
margin-right:auto; /* Centering for Web browsers other than Internet Explorer */
width:300px; /* Width */
height:180px; /* Height */
color:#ffffff; /* Character color */
}
-->
</style>
</head>
<body>
<!-- Company logo image display settings --> 4
<img src="./img/companylogo.png" alt="" width="132" height="36" border="0" />
<!-- Web page title text display -->
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
<h2><u>Menu</u></h2>
<!-- Display of (three) Web page switching buttons -->
<div class="web-center">
<p>
<a href="index1.html" class="button1">1. Pressure Meter</a>
</p>
<p>
<a href="index2.html" class="button2">2. Temperature Change Graph</a>
</p>
<p>
<a href="index3.html" class="button3">3. Device Monitor</a>
</p>
</div>
</body>
</html>
27
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
2 [Design example] Use different colors to indicate the designs of the Web page switching buttons.
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
Company logo
Menu
1. Pressure Meter
3. Device Monitor
3
[Style Sheet]
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
28
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
Store the created files so that the file structure is as shown below.
index.html
index.html
Store this file in the “USER” folder.
WWW USER 2
Log-in_User.html
UserWebStyle.css
css
button-menu.css
button-menu.css
Store this file in the “css” folder.
companylogo.png
img
3
STEP 4. Check whether the page can be displayed correctly in a Web browser.
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
29
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
This section explains the procedure for creating the pressure meter page.
Level display objects and a button for switching the Web page are displayed on the page created with this example. Reuse and
edit “index.html” to create the level display objects and use a Style Sheet to design the button for switching the Web page.
uSpecifications
[Design example]
2
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
123 22500
Web page switching
Menu button display Link destination
• Design (Style Sheet) • index.html
• Page switching
uFunctions to use
3
Reference
Function Creation method Example/special note
section
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
Background color Style Sheet Write a Style Sheet inside the HTML file. 7.1
Use an HTML tag to display the image.
Image display <img> tag
<img src="image file name" alt="alternatively displayed text">
Font size <h3></h3> tags <h3>Heading 3</h3> 7.2
Text display Underline <u></u> tags <u>Text in this range is underlined.</u>
Paragraph <p></p> tags Use <p></p> to indicate paragraphs and insert line breaks.
Level display objects (two) Reuse the “level display object” in the HTML file in the user Web page library.
Devices D0 and D1
Change the evLength:, levWidth:, devValWidth:, and 5.4
Size
JavaScript devValHeight: parameters.
Display starting
Change the xPos: and yPos: parameters.
coordinates
When the button is clicked, its display changes to that shown
4 Design Style Sheet
on the right.
switching button
Before being clicked After being clicked 7.1
display
(return to the menu) Page switching <a></a> tags <a href="link destination URL">Displayed text</a>
Display starting Embed a Style Sheet in the <a> tag to display the button in the
Style Sheet
coordinates lower-right corner.
uFiles to create
File type File name Remarks
Linked from the menu page.
HTML level.html
If the file name is changed, the menu page needs to be corrected.
This file can be named as desired. If you change it, also change the file name
Style Sheet button-menu.css
of the Style Sheet file in the link settings of the HTML file.
uRequired files
File type File name Remarks
JavaScript FUserWebLib.js Required for displaying the level display objects.
Style Sheet UserWebStyle.css Use a <link> tag to set links to the files on the left.
30
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
uCreation procedure
Create this component by reusing the file “index.html” included in the user Web page library obtained from the Mitsubishi Electric
representative.
In Notepad, open the “index.html” file from the user Web page library.
Notepad
This prevents the original file from being overwritten incorrectly with the HTML file created by reusing the original.
STEP 3. Delete the lines (sections) that are unnecessary for the Web page being created from the HTML. 4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
Delete everything other than the sections for the level display objects.
For details on the lines to delete, refer to the next page.
Starting with STEP 3, use “level.html”. Exercise caution to avoid correcting the wrong file.
X0 X1 X7 OK
NG
X0 X1 X7
Level display
object (first)
Log Out 0
31
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
Sections to reuse
To create a Web page that uses a pressure meter (level display objects), reuse the sections indicated by “Do not delete.” in the
following table from the user Web page library (index.html) and delete the other sections indicated by “Delete”.
Pressure
Line No. HTML
meter
1 <!DOCTYPE html>
2 2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
4 <!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
5 <meta charset="UTF-8">
6 <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
Do not delete.
7 <!-- Set the title. -->
8 <title>Sample</title>
9 <link href="./css/UserWebStyle.css" rel="stylesheet" media="all" />
10 <!-- Reading the library JavaScript (Change the path to match the storage location.) -->
11 <script src="./FUserWebLib.js"></script>
12 <!-- Write the proprietary JavaScript from this point. -->
13 <!-- Write the user JavaScript here. -->
14 <script>
15 var updateInterval = 5;
16 var dspLanguage = 'en-US';
17
18 // Data Block object
3 19 temp = [];
20 for(var i = 0; i < 8; i++){
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
21 temp.push({
22 dsp: 'X' + i,
23 name: 'X' + i,
24 base: 'B',
25 format: 6
26
27 });
28 }
29 for(var i = 0; i < 8; i++){
30 temp.push({
31 dsp: 'Y' + i,
32 name: 'Y' + i,
33 base: 'B',
34 format: 6
35
4 36 });
Delete.
37 }
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
38 dataBlockParam = {
39 dev: temp,
40 direction: 1,
41 blkSize: 8,
42 devNamDisp: 1,
43 devNamCol: 'white',
44 devNamBkCol: '#808080',
45 devNamWidth: 100,
46 devNamHeight: 40,
47 devValCol: 'blue',
48 devValBkCol: 'white',
49 devValWidth: 80,
50 devValHeight: 50,
51 lnCol: 'blue',
52 xPos: 20,
53 yPos: 40
54 }
55 WSDatblk(dataBlockParam);
56
32
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
Pressure
Line No. HTML
meter
Delete.
78 upper: 32767, //100,
79 lower: -32768, //0,
80 xLine: 9, 3
81 yLine: 5,
99 WSLogoutBtn(logoutBtnParam);
100
33
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
Pressure
Line No. HTML
meter
Do not delete.
112 lowerAlmV: -20000,
113 dspAlmLn: 1,
114 almLnCol: 'black',
115 levLength: 400,
116 levWidth: 150,
117 dspVal: 1,
118 valFormat: 0,
119
120 devValCol: 'white',
121 devValBkCol: 'black',
122 devValWidth: 150,
123 devValHeight: 50,
3 124 xPos: 700,
125 yPos: 250,
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
126 });
127
128 // Write button object
129 WSWrtBtn({
130 devName: 'X0',
131 devBase: 'B',
132 devFormat: 6,
133
134 wrVal: '1',
135 wrBtn: 'write_btn',
136 btnTxt: 'OK',
137 btnWidth: 150,
138 btnHeigh: 50,
139 wrComfirm: 1,
140 language: 1,
4 141 xPos: 700,
142 yPos: 40,
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
143 });
Delete.
144
145 // Write button object
146 WSWrtBtn({
147 devName: 'X0',
148 devBase: 'B',
149 devFormat: 6,
150
151 wrVal: '0',
152 wrBtn: 'write_btn',
153 btnTxt: 'NG',
154 btnWidth: 150,
155 btnHeigh: 50,
156 wrComfirm: 1,
157 language: 1,
158 xPos: 700,
159 yPos: 130,
160 });
161
34
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
Pressure
Line No. HTML
meter
Delete.
186 });
213 <body>
214 </body>
215 </html>
35
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
…
18 // Level display object
…
2 41
42
xPos:
yPos:
700,
250,
43 });
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
44 </script> Addition
45 </head>
46 <body>
47 </body>
48 </html>
STEP 5. Correct items such as the size and display coordinates of the (first) level display object.
Correct items such as the size and display coordinates of the (first) level display object.
…
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
36
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
41 xPos: 100,
42 yPos: 50,
Copy lines 18 to 43 and paste these 2
43 });
lines between lines 43 and 44.
STEP 7. Correct the display position and size of the (second) level display object.
66 devValHeight: 50,
67 xPos: 100, 300, Display starting coordinates
68 yPos: 50,
69 });
70 </script>
71 </head>
72 <body>
73 </body>
74 </html>
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
37
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
Add the HTML for the background color between lines 13 and 14.
If the background color is white, there is no need to add this HTML.
10 <!-- Reading the library JavaScript (Change the path to match the storage location.) -->
2 11 <script src="./FUserWebLib.js"></script>
12 <!-- Write the proprietary JavaScript from this point. -->
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
</style>
14 <script>
15 var updateInterval = 5;
16 var dspLanguage = 'en-US';
STEP 9. Change the page title and add a Web page switching button.
Change the page title on line 8, and then add the HTML for the Web page switching button between lines 77 and 78.
3
Line No. HTML
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
77 <body>
<!-- Web page title text display -->
<h2><u>1. Pressure Meter</u></h2>
<!-- Display of Web page switching button -->
<a href="index.html" class="menu" style="position: absolute; left: 350px; top: 550px;" />Menu</a>
78 </body>
79 </html>
1. Pressure Meter
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
Menu
38
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
STEP 10. Add the <link> setting to Style Sheet file for Web page switching button.
Add the HTML for the <link> settings of the Style Sheet file for the Web page switching button between lines 9 and 10.
STEP 11. Create Style Sheet files for the Web page switching button.
This button is used on the “pressure meter page”, “temperature change page”, and “device monitor page”.
[Design example] Indicate the design of the Web page switching button.
3
1. Pressure Meter
Menu
[Style Sheet]
class attributes: menu
a.menu{
display: block; 4
text-decoration: none;
height: 37px;
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
width: 250px;
line-height: 37px;
text-align: center;
color: #fff;
background: #4169e1;
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-ms-transition: 0.3s;
transition: 0.3s;
}
a.menu:hover{
background: #fff;
color: #4169e1;
border:solid 1px #4169e1;
}
39
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
Store the created files so that the file structure is as shown below.
index.html
2 WWW USER
level.html
level.html
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
Log-in_User.html
FUserWebLib.js
UserWebStyle.css
css
button-menu.css
button-back.css
button-back.css
Store this file in the “css” folder.
3
companylogo.png
companylogo.png
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
STEP 13. Check whether the page can be displayed correctly in a Web browser.
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
40
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
This section explains the procedure for creating the temperature change page.
A historical graph object and a button for switching the Web page are displayed on the page created with this example. Reuse
and edit “index.html” to create the historical graph object and use a Style Sheet to design the button for switching the Web page.
uSpecifications
[Design example]
2
Text display Background color
2. Temperature Change Graph
uFunctions to use
Function Creation method Example/special note
Reference 3
section
menu)
Display starting Embed a Style Sheet in the <a> tag to display the button in
Style Sheet
coordinates the lower-right corner.
uFiles to create
File type File name Remarks
Linked from the menu page.
HTML historical.html
If the file name is changed, the menu page needs to be corrected.
This file can be named as desired. If you change it, also change the file
Style Sheet button-back.css
name of the Style Sheet file in the link settings of the HTML file.
uRequired files
Use the files in the user Web page library as-is.
File type File name Remarks
41
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
uCreation procedure
Create this component by reusing the file “index.html” included in the user Web page library obtained from the Mitsubishi Electric
representative.
In Notepad, open the “index.html” file from the user Web page library.
2
Notepad
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- Set the title. -->
<title>Sample</title>
<link href="./css/UserWebStyle.css" rel="stylesheet" media="all" />
<!-- Reading the library JavaScript (Change the path to match the storage location.) -->
<script src="./UserWebLib.js"></script>
<!-- Write the proprietary JavaScript from this point. -->
<!-- Write the user JavaScript here. -->
<script>
var updateInterval = 5;
var dspLanguage = 'en-US';
3
name: 'X' + i,
base: 'B',
format: 6
});
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
This prevents the original file from being overwritten incorrectly with the HTML file created by reusing the original.
STEP 3. Delete the lines (sections) that are unnecessary for the Web page being created from the HTML.
Delete everything other than the sections for the level display objects.
4
Starting with STEP3, use “historical.html”. Exercise caution to avoid correcting the wrong file.
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
X0 X1 X7 OK
NG
X0 X1 X7
Log Out 0
42
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
Sections to reuse
To create a Web page that uses a temperature change graph (historical graph object), reuse the sections indicated in the
following table from the user Web page library (index.html) and delete all the other sections.
Temperature
Line No. HTML change
graph
1 <!DOCTYPE html> 2
2 <html xmlns="http://www.w3.org/1999/xhtml">
Do not delete.
7 <!-- Set the title. -->
8 <title>Sample</title>
9 <link href="./css/UserWebStyle.css" rel="stylesheet" media="all" />
10 <!-- Reading the library JavaScript (Change the path to match the storage location.) -->
11 <script src="./FUserWebLib.js"></script>
12 <!-- Write the proprietary JavaScript from this point. -->
13 <!-- Write the user JavaScript here. -->
14 <script>
15 var updateInterval = 5;
16 var dspLanguage = 'en-US';
17
18 // Data Block object 3
19 temp = [];
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
37 }
38 dataBlockParam = {
39 dev: temp,
40 direction: 1,
41 blkSize: 8,
42 devNamDisp: 1,
43 devNamCol: 'white',
44 devNamBkCol: '#808080',
45 devNamWidth: 100,
46 devNamHeight: 40,
47 devValCol: 'blue',
48 devValBkCol: 'white',
49 devValWidth: 80,
50 devValHeight: 50,
51 lnCol: 'blue',
52 xPos: 20,
53 yPos: 40
54 }
55 WSDatblk(dataBlockParam);
56
43
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
Temperature
Line No. HTML change
graph
64 temp.push({
65 devName: 'D1',
66 lnCol: 'blue',
67 });
68 hstGrpParam = {
69 xPos: 20,
70 yPos: 250,
71 grElmNum: num,
Do not delete.
72 devFormat: 0,
73
74 grElm: temp,
75 grBkCol: '#F0F0F0',
76 dspCol: 'black',
77 pointNum: 20,
78 upper: 32767, //100,
3 79 lower: -32768, //0,
80 xLine: 9,
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
81 yLine: 5,
82 grHeight: 380,
83 grWidth: 550,
84 upperMargin: 15,
85 leftMargin: 75,
86 lowerMargin: 55,
87 rightMargin: 25
88 }
89 WSHstgrp(hstGrpParam);
90
91 // Logout button object
92 logoutBtnParam = {
93 xPos: 20,
94 yPos: 730,
Delete.
95 btnHeigh: 26,
4 96 btnWidth: 100,
97 btnTxt: 'Log Out'
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
98 }
99 WSLogoutBtn(logoutBtnParam);
100
44
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
Temperature
Line No. HTML change
graph
Delete.
131 devBase: 'B',
132 devFormat: 6,
133
134 wrVal: '1',
135 wrBtn: 'write_btn',
136 btnTxt: 'OK',
137 btnWidth: 150,
138 btnHeigh: 50,
139 wrComfirm: 1,
140 language: 1, 4
141 xPos: 700,
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
45
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
Temperature
Line No. HTML change
graph
Delete.
186 });
187
188 // Image display object
189 WSPicture({
190 devName: 'D0',
191 devFormat: 0,
192
193 pictHeight: 30,
194 pictWidth: 30,
195 defPicture: './img/sample0.png',
196 rangeNum: 2,
197 range:[
198 {
199 low: -5000,
200 high: 5000,
4 201 picture: './img/sample1.png',
202 },
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
203 {
204 low: -10000,
205 high: 10000,
206 picture: './img/sample2.png',
207 },
208 ],
209 xPos: 200,
210 yPos: 730,
211 }); </script>
212 </head>
delete.
Do not
213 <body>
214 </body>
215 </html>
46
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
47 lowerMargin: 55,
STEP 5. Correct items such as historical graph object size and display coordinates.
Correct items such as the size and display coordinates of the historical graph object.
29 hstGrpParam = {
30 xPos: 20,
31 yPos: 250, 60,
32 grElmNum: num,
…
47
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
Add the HTML for the background color between lines 13 and 14.
If the background color is white, there is no need to add this HTML.
10 <!-- Reading the library JavaScript (Change the path to match the storage location.) -->
11 <script src="./FUserWebLib.js"></script>
2 12 <!-- Write the proprietary JavaScript from this point. -->
13 <!-- Write the user JavaScript here. -->
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
<style>
body {
background-color: sandybrown;
}
</style>
14 <script>
15 var updateInterval = 5;
16 var dspLanguage = 'en-US';
STEP 7. Change the page title and add a Web page switching button.
Change the page title on line 8, and then add the HTML for the Web page switching button between lines 58 and 59.
…
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
58 <body>
<!-- Web page title text display -->
<h2><u>2. Temperature Change Graph</u></h2>
<!-- Display of Web page switching button -->
<a href="index.html" class="menu" style="position: absolute; left: 500px; top: 550px;" />Menu</a>
59 </body>
60 </html>
Menu
48
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
STEP 8. Add the <link> setting to Style Sheet file for Web page switching button.
Add the HTML for the <link> settings of the Style Sheet file for the Web page switching button between lines 9 and 10.
STEP 9. Create Style Sheet files for the Web page switching button.
[Design example] Indicate the design of the Web page switching button.
3
2. Temperature Change Graph
[Style Sheet]
class attributes: menu
a.menu{
display: block; 4
text-decoration: none;
height: 37px;
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
width: 250px;
line-height: 37px;
text-align: center;
color: #fff;
background: #4169e1;
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-ms-transition: 0.3s;
transition: 0.3s;
}
a.menu:hover{
background: #fff;
color: #4169e1;
border:solid 1px #4169e1;
}
49
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
index.html
WWW USER
2
level.html
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
historical.html
historical.html
Store this file in the “USER” folder.
Log-in_User.html
FUserWebLib.js
UserWebStyle.css
css
button-menu.css
3 button-back.css
button-back.css
Store this file in the “css” folder.
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
STEP 11. Check whether the page can be displayed correctly in a Web browser.
50
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
This section explains the procedure for creating the device monitor page.
Device reading CGI, device writing CGI, and a button for switching the Web page are displayed on the page created with this
example. Use a Style Sheet to design the buttons for switching the Web page.
This Web page does not reuse index.html. Refer to the following chapter to create the HTML.
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
uSpecifications 2
[Design example]
uFiles to create
File type File name Remarks
51
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
uProcedure
This section explains an outline procedure for using CGI objects to create HTML for reading/writing from/to devices.
Corrections
Additions
device.html
Create the HTML
Start Notepad. Create the HTML document Add the HTML contained in Create the HTML document by reusing the
Save an empty document by reusing the HTML this guide to the existing HTML contained in this guide.
with the file name contained in this guide. HTML document.
“device.html”.
For details on the HTML file, For details on the HTML file,
Select “UTF-8” for the refer to the following. refer to the following.
Encoding before saving
the file. 6.4 Device Reading 6.5 Device Writing
Web Page Creation Web Page Creation
3
STEP 1.
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
Starting with STEP2, use “device.html”. Exercise caution to avoid correcting the wrong file.
Reuse the entire HTML written on the following page (<!DOCTYPE html> to </html>) to create the HTML file.
Related Page 6.4 Device Reading Web Page Creation - HTML creation example - HTML
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
[Created details]
Create a file
Line No. HTML with the HTML device.html
contained in this
Declaration area (start) 1 <!DOCTYPE html> <!DOCTYPE html>
guide.
Information area
……
……
……
Body area
Declaration area (end) 117 </html> </html>
52
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
Add two sections from the device writing CGI written in this guide to the following locations.
Related Page 6.5 Device Writing Web Page Creation - HTML creation example - HTML
1 Insert lines 10 (<script>) to 79 (</script>) of the device writing CGI sample HTML in the space between </script> and </head> in
device.html.
2
2 Insert lines 83 (<form>) to 111 (</form>) of the device writing CGI sample HTML in the space between </form> and </body> in
[Created details]
……
……
Information area
79 </script> </script>
80 </head> </head>
3
82 <body> <body>
……
……
Body area
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
53
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
STEP 4. Correct HTML for coexistence with the device writing CGI.
Make corrections to use both the device reading CGI and a device writing CGI on a single Web page.
In this example, the device writing CGI ID names are corrected to values between 10 and 19 to prevent them from duplicating the
ID names used with the device reading CGI.
If these corrections are not made, the PLC and device reading/writing cannot be performed correctly.
[Correction details]
2
(1) (2) (3)
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
201 <form>
202 <table id="devtbl2" class="devtbl" border="1">
203 <tr>
3 204 <th>Device name</th>
205 <th>Data type</th>
<th>Value</th>
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
206
</tr>
207
<tbody>
208
<tr> Before change After change
209
210 <td><input type="text" id="DEV10" name="DEV1" class="input" value="D10"/></td>
<td><input type="text" id="TYP10" name="TYP1" class="input" value="16-bit integer"/></td> (1)
211
<td><input type="text" id="DATA10" name="DATA1" class="input" value="3"/></td>
212
213 <td><input type="button" value="Write" class="input" onclick="WriteDeviceBlockTbl('devtbl2',1)"/></td>
214 </tr>
215 <tr>
216 <td><input type="text" id="DEV11" name="DEV1" class="input" value="D11"/></td>
217 <td><input type="text" id="TYP11" name="TYP1" class="input" value="32-bit integer"/></td> (2)
218 <td><input type="text" id="DATA11" name="DATA1" class="input" value="10"/></td>
219 <td><input type="button" value="Write" class="input" onclick="WriteDeviceBlockTbl('devtbl2',2)"/></td>
220 </tr>
221 <tr>
222 <td><input type="text" id="DEV12" name="DEV1" class="input" value="M0"/></td>
4 223
224
<td><input type="text" id="TYP12" name="TYP1" class="input" value="Bit"/></td>
<td><input type="text" id="DATA12" name="DATA1" class="input" value="1"/></td>
(3)
225
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
54
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
Add the HTML for the background color between lines 9 and 10.
If the background color is white, there is no need to add this HTML.
STEP 6. Change the page title and add a Web page switching button.
Change the page title on line 8, and then add the HTML for the Web page switching button between lines 158 and 159.
156 </script>
157 </head>
158 <body>
<!-- Web page title text display -->
<h2><u>3. Device Monitor</u></h2>
<!-- Display of Web page switching button -->
<a href="index.html" class="menu" style="position: absolute; left: 400px; top: 350px;" />Menu</a>
159 <form>
160 <table id="devtbl" class="devtbl" border="1">
Menu
55
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
STEP 7. Add the <link> setting to Style Sheet file for Web page switching button.
Add the HTML for the <link> settings of the Style Sheet file for the Web page switching button between lines 8 and 9.
STEP 8. Create the Style Sheet file for Web page switching button.
This button is used on the “pressure meter page”, “temperature change page”, and “device monitor page”.
[Design example] Indicate the design of the Web page switching button.
3
3. Device Monitor
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
Menu
[Style Sheet]
class attributes: menu
4 a.menu{
display: block;
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
text-decoration: none;
height: 37px;
width: 250px;
line-height: 37px;
text-align: center;
color: #fff;
background: #4169e1;
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-ms-transition: 0.3s;
transition: 0.3s;
}
a.menu:hover{
background: #fff;
color: #4169e1;
border:solid 1px #4169e1;
}
56
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
index.html
WWW USER
level.html
historical.html
2
Log-in_User.html
FUserWebLib.js
UserWebStyle.css
css
button-menu.css
button-back.css
button-back.css Store this file in the “css” folder.
3
STEP 10. Check whether the page can be displayed correctly in a Web browser.
Double-click the “device.html” file.
If the following dialog box is displayed, click “Allow blocked content”.
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
57
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
2
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
Relevant Web Server Function Application Guide Using Web Page Startup and Introduction
documents [manual number: L(NA)08643ENG]
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
58
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
Store the created user Web server files on an SD memory card. This section explains the destination in which to save the user Web
server files. If you want to change the file structure, consider this action by referring to the following explanation.
This section explains the file structure of the user Web page library.
The following figure shows the file structure stored on the SD memory card with the file group provided by the user Web page library
2
and the user-created file group. Changing the folder structure or file names of the user library may prevent normal operation.
Log-in_User.html
$MELPRJ$
JavaScript file
FUserWebLib.js 3
css UserWebStyle.css
img sample0.png
***_1.html
Files to which the user Web page will
be switched
Files can be named as desired.
***_*.html
Folder_* File_*
59
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
There is normally no need to change the folder structure or file names, but use the information here as a reference when sorting
by folder and when storing other JavaScript files in the folders. The explanation here covers JavaScript and Style Sheet files.
JavaScript files
uFile name
File name Function Description Default storage destination
A file included in the user Web
2 FUserWebLib.js Library of JavaScript objects
page library
./FUserWebLib.js
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
uHTML document
This section explains how to read JavaScript files from HTML files and how to change the path according to the file storage location.
u When the “index.html” and “FUserWebLib.js” files are on the same level (default storage destination)
<script src="./FUserWebLib.js"></script>
Log-in_User.html
FUserWebLib.js
3
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
<script src="./js/FUserWebLib.js"></script>
Log-in_User.html
js FUserWebLib.js
4 (<script> ).
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
</head>
60
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
uFile name
File name Function Description Default storage destination
File with commonly defined
UserWebStyle.css Style settings ./css/UserWebStyle.css
styles
uHTML document 2
This section explains how to read CSS files from HTML files.
u When the “index.html” and “UserWebStyle.css” files are on the same level
<script src="./UserWebStyle.css"></script>
Log-in_User.html
UserWebStyle.css
u When the “UserWebStyle.css” file is stored in the css folder (default storage destination) 3
<script src="./css/UserWebStyle.css"></script>
Log-in_User.html
css UserWebStyle.css
</head>
61
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
BASICS OF CREATING HTML < TAGS >
Before Starting Preparation Reuse User Web Page Creation File Save Destination Troubleshooting
3.6 Troubleshooting
[Example 1] When the Style Sheet file is stored in the css folder
Bad <link href="./cssss/button-n enu.css" rel="stylesheet" media="all"/>
Good <link href="./css /button-m enu.css" rel="stylesheet" media="all"/>
[Example 2] When the Style Sheet file is stored in the css folder
[Example 2] Bad <link href="button-back.css" rel="stylesheet" media="all" />
Good <link href="/.css /button-back.css" rel="stylesheet" media="all" />
[Example 1]
Bad HTML <a href="level.html" class="button1">1. Pressure Meter</a>
3 Style Sheet a.button{
Good HTML <a href="level.html" class="button1">1. Pressure Meter</a>
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
For the HTML file on the personal computer, the Web Check whether the Style Sheet files (button-menu.css and button-back.
page switching button can be displayed with the css) are stored on the SD memory card.
correct style in a Web browser. However, it cannot be
displayed correctly on the PLC-side Web page.
WWW USER
Personal computer CPU module
Style Sheet for the buttons used
on the menu Web page
css button-menu.css
Style Sheet for the button used to
On the
return to the menu Web page
personal computer SD memory card button-back.css
Web files Web files
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
The Web page is not displayed in a Web browser. An All the HTML files cannot be referenced from the HTML file that you
error is displayed instead. attempted to display.
Check the following details.
Ex. When all the HTML files are stored in the same location
<a href="level.htm " class="button1">1. Pressure Meter</a>
File name extension mistake
<a href="/.user/historical.html" class="button2">2. Temperature Change Graph</a>
Storage location specification mistake
<a href="device.html class="button3">3. Device Monitor</a>
["] missing after device.html
62
1
3. USING CUSTOMIZATION TO EASILY CREATE A USER WEB PAGE
Search... Search...
Menu Menu
On the
personal computer SD memory card
63
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
BASICS OF CREATING HTML < TAGS >
What Are Style Sheets? Common Items Overall Structure Setting Details Style Sheet Details
A Style Sheet is a way to change the style of a Web page such as its design and layout. Whereas HTML defines the elements and
structure of the Web page, the Style Sheet specifies how to decorate the elements and structure.
When specifying the style of a Web page created with a language such as HTML or XHTML, CSS (Cascading Style Sheets), one type
of Style Sheet languages is most commonly used. Therefore, Style Sheets may generally be referred to as “CSS”.
uWeb page that does not use a Style Sheet uWeb page that uses a Style Sheet
2
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
3
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
Create the foundation of the Web page with HTML. The colors, lines, and layout can be changed with a Style Sheet.
Use a CSS file to arrange the appearance of the text displayed in a browser with an HTML file. Separating the text
Point and appearance into different files has a variety of advantages including making it possible to write these items by
focusing on their separate details and making it easier to divide work among multiple people.
CSS code
p{
color: orange
}
64
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
This section explains the common items that you need to know to use Style Sheets.
Terminology
Item Description
Selector Target to which the Style Sheet will be applied.
Property Name of the style to apply. 2
Property value Details of the style to apply.
Each Style Sheet statement consists of a selector, property, and property value.
Ex.
Property
Selector { Property : value ;}
What to
body { color : #ff0000 ;}
Target How to change it
change
Declaration
uRead the Style Sheet from a CSS file with a <link> tag.
Write the Style Sheet into a file with the “.css” extension, and then link to the CSS file from an HTML file to read the Style Sheet. To
link to the CSS file from an HTML file, use the <link> tag within the <head> tag.
Ex. Linking to “UserWebStyle.css” in the user Web page library
<head>
<link href="./css/UserWebStyle.css" rel="stylesheet" media="all" />
</head>
Ex. Adding a Style Sheet that makes the body character color red
<head>
<style>
body { color: #ff0000; }
</style>
</head>
65
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
BASICS OF CREATING HTML < TAGS >
What Are Style Sheets? Common Items Overall Structure Setting Details Style Sheet Details
This section shows a setup example of using the <style> tag to write a Style Sheet.
To set the character color (property) of the body (selector) to red (property value), write the Style Sheet as shown below.
body { color:#ff0000; }
The above Style Sheet changes the color of the text between the <body> and </body> tags to “#ff0000 (red)”.
2 uHTML example
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- Set the title. -->
<title>Style Sheet(css)_selector</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<!--Character color specification for the text between <body> and </body> in the Web page-->
<style>
body { color:#ff0000; }
</style>
3 </head>
<body>
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
This example shows how to specify the character color with a Style Sheet (css).
</body>
</html>
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
66
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
The HTML document <link> tag is used to read the Style Sheet file.
JavaScript objects
* This is not used by the user Web page library HTML file
(index.html) from the Mitsubishi Electric representative.
The style of each object set with JavaScript takes priority, and even if the settings are changed with the Style Sheet (UserWebStyle.
4
css), these changes are not applied. However, if specific settings are omitted in the JavaScript, the Style Sheet settings are applied.
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
If you change the Style Sheet (UserWebStyle.css) in the user Web page library, do not change the Style Sheet
Special Note
class names. However, do not define Style Sheet class names with the same names.
67
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
BASICS OF CREATING HTML < TAGS >
What Are Style Sheets? Common Items Overall Structure Setting Details Style Sheet Details
This section explains the details of the Style Sheet file (UserWebStyle.css) in the user Web page library.
When you change a Style Sheet file, setting parameters and values incorrectly will prevent the objects from
Caution
2 being displayed in the Web browsers. Be sure to save a copy of the file before making changes.
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
Setting of parameter "dev[0].base" is incorrect. Invalid data format for device "D0"
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
Log Out
68
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
uList of parameters
• Error message display button • Cursor
width background-color
cursor
height
2
: padding : margin *: Colors are used in the figure to clearly identify the padding
and margin locations.
margin-top
padding
Setting of parameter "dev[1].base" is incorrect.
margin-left
Setting of parameter "dev[2].base" is incorrect.
background-color 3
69
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
BASICS OF CREATING HTML < TAGS >
What Are Style Sheets? Common Items Overall Structure Setting Details Style Sheet Details
uStyle Sheet
Line No. Style Sheet statement Explanation
15 }
Error message display field Window that displays the error message list
16 .errorField{ Selector
17 position: absolute; Placement of the absolute position of the parent box
18 z-index: 2147483646; Specifies the box overlapping order.
19 margin-top: 22px; /* errorButton height + margin-top */ Outer margin specification (top)
20 margin-left: 2px; /* Same value as errorButton margin-left */ Outer margin specification (left)
21 background-color: white; Background color
border: solid 1px black; Error message display field border specification
22 Setting values [thickness: 1 pixel, line type: solid
line, line color: black]
23 }
70
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
uList of parameters
background-color:
Object 001 Object 002 Object 003 Object 004 Object 005
71
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
BASICS OF CREATING HTML < TAGS >
What Are Style Sheets? Common Items Overall Structure Setting Details Style Sheet Details
uList of parameters
32767
stroke:
stroke-width:
stroke-linejoin:
2
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
background-color:
-32768
font-size:
2018-12-05 11:04:06 2018-12-05 11:05:41
uStyle Sheet
Line No. Style Sheet statement Explanation
66 /* ------------------------------------------------------------------------------ */
Parts enclosed in “/*” and “*/” are handled as
67 /* Historical graph object */
comments.
68 /* ------------------------------------------------------------------------------ */
69 .hstgrp{ Selector
70 border: 1px solid black;
Not used
3 71 background-color: white;
72 }
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
73 .hstgrp_frame{ Selector
74 stroke: black; Line color specification
75 stroke-width: 1px; Line thickness specification
76 stroke-linejoin: miter; Line joint and angle shape specifications
77 }
78 .hstgrp_text_x,
Selector
79 .hstgrp_text_y{
80 font-size: 18px; Font size specification
81 }
82 .hstgrp_line{ Selector
83 stroke: blue;
84 stroke-width: 1px; Not used
85 stroke-linejoin: round;
86 }
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
72
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
uList of parameters
color:
uList of parameters
uStyle Sheet
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
73
1
4. LEARNING THE FUNCTIONS OF STYLE SHEETS (CSS)
BASICS OF CREATING HTML < TAGS >
What Are Style Sheets? Common Items Overall Structure Setting Details Style Sheet Details
uList of parameters
2
DOCUMENTS ON A PERSONAL COMPUTER
CREATING AND DISPLAYING SIMPLE HTML
font-weight:
uStyle Sheet
Line No. Style Sheet statement Explanation
107 /* ------------------------------------------------------------------------------ */
Parts enclosed in “/*” and “*/” are handled as
108 /* Level display object (style) */
comments.
109 /* ------------------------------------------------------------------------------ */
110 .partsLevelValue{ Selector
Font decoration type specification
111 font-weight:bold;
Setting value [bold]
3 }
112
A USER WEB PAGE
USING CUSTOMIZATION TO EASILY CREATE
4
SHEETS (CSS)
LEARNING THE FUNCTIONS OF STYLE
74
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
JavaScript is a language for adding functions to Web pages. This makes it possible to realize interactive operations such as
displaying photograph slides and 2D/3D graphical animations.
By obtaining the user Web page library from the Mitsubishi Electric representative, you can use a JavaScript (JS) tool library.
This section explains the parameters of the JavaScript library objects. In this chapter, no details are listed regarding the general
writing of JavaScript.
List of objects
6
WITH CGI
CREATING A DEVICE MONITOR WINDOW
You can use the JavaScript objects in the user Web page library to read/write from/to devices from user Web pages.
The objects in the following table are included JavaScript object library (FUserWebLib.js).
Table
Data Block object (WSDatblk)
Object 001 Object 002 Object 003 Object 004 Object 005
Object 101 Object 102 Object 103 Object 104 Object 105
Graphs
7
Level display object (WSLevel) Historical graph object (WSHstgrp)
REFERENCES
Write button display
Displays device value ratios as a bar graph. Displays device data as a chronological order line graph.
Images
Image display object (WSPicture) Figure display object (WSFigure)
0 1 2
Displays the specified image when the device value reaches Displays the specified figure when the device value reaches
the set value. the set value.
Operation buttons
Write button object (WSWrtBtn) Logout button object (WSLogoutBtn)
* Write 1 to X0.
* Write 0 to X0.
Writes the specified value to the specified device. Executes the logout operation.
*: The text displayed on the button can be changed.
75
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Usable files
Relationship between the extensions and MIME types of files on the Web
The concept of “extensions” and “MIME types” exists on the Web.
This is a mechanism for identifying the file type as text or HTML and for identifying the format of image files.
• The “extension” indicates what the file is. The extension is the last part of the file name from the dot (“.”) to the end.
• “MIME type” is a character string in the format of “type name/subtype name”. This “MIME type” is used to specify
Terminology the data format between Web servers and Web browsers. When a Web browser requests the “xxx.png” file from a
Web server, the Web server returns the details of "xxx.png” that it is an image/png type data. This enables the Web
browser to process the received data correctly.
• The MIME type is specified by writing “Content-Type” in the HTML document.
Ex. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
Item Default
Character color Black
Background color White
Line color Black
Level display fill color Blue
Graph line color Blue
Font size 20 (in pixels)
Button character color Follows the Web browser settings.
Button background color Follows the Web browser settings.
Button line color Follows the Web browser settings.
The roles of the different parts of a JavaScript description are classified as shown below. The object explanation pages are color-
coded according to these roles.
HTML file
Declarations JavaScript object
for usage JavaScript file library file Web browser display
Next page link settings
Title
File Edit View Favorites Tools Help
Parameter FUserWebLib.js
descriptions Object position, color,
File
device, and other such
Explained for
each object specifications
76
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
This section explains the common items that you need to know to use JavaScript objects.
The parameters that follow the display object name are organized as shown below.
Ex.
Display object name { .partsBase { 6
: ; : ;
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Parameter name Space Value (setting) Parameter setting position absolute
} }
Parameter specification
This section explains the parameter specifications that follow the display object name.
Description Default
Specification When the parameter of an optional setting is Displayed with the default settings. 7
omitted omitted
REFERENCES
Incorrect When the setting of a parameter is incorrect
specification
When set with a data format other than the For example, a parameter error occurs when a character string
Data format specified one such as “XYZ” is specified for a parameter that is set with a numeric
value. Set each parameter with its specified data format.
Coordinate When the X and Y coordinates are omitted The object is placed in the upper-left corner (coordinates 0, 0).
specification
Range check of the RGB value or color name In the HTML specifications, a range check of items such as the
Color RGB value and color name is not performed. If an incorrect setting
specification is specified, the displayed details vary depending on the type of
Web browser.
Device When specifying a “U\G” device name Use two “\” characters to specify a name as “U\\G”. (The first “\”
specification is an escape sequence*.)
* An escape sequence is a special character that is not output as-is and instead is used to control the output of characters such as to change the
character color, move the cursor, and delete characters.
77
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
The settable formats and number bases of the devices that can be set in JavaScript objects are shown below.
*1: When T, ST, C, or LC is specified, it is handled as the device of the current value (TN, STN, CN, or LCN).
*2: When specifying a device name that includes the “\” character such as “U\G”, use two “\” characters to specify the name as “U\\G”.
The first “\” (escape sequence) is a symbol that has the meaning of a special character, so the above expression is required.
78
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
6
uSetting examples
WITH CGI
CREATING A DEVICE MONITOR WINDOW
• Specifying input X7 • Specifying timer T25 (current value)
uCorrespondence table
JavaScript parameter name
1 Device 2 Data number 3 Data format 2 Data number base
Device name Classification name base
devFormat: Setting Description
devName: devBase:
2 K 2 H value
User devices K Decimal
REFERENCES
Internal relay (M) Bit M B 6
Latch relay (L) Bit L B 6 3 Data format
Link relay (B) Bit B B 6
Setting Description
Annunciator (F) Bit F B 6
value
Link special relay (SB) Bit SB B 6
0 16-bit signed
Step relay (S) Bit SB B 6
1 16-bit unsigned
Contact: TS Bit TS B 6
2 32-bit signed
Timer Coil: TC Bit TC B 6
(T) 3 32-bit unsigned
Current value:
Word TN K, H 0 1 4 Single-
TN
precision real
Contact: STS Bit STS B 6
number
Accumulation Coil: STC Bit STC B 6
5 Not used
timer (ST) Current value:
Word STN K, H 0 1 6 Bit
STN
Contact: CS Bit CS B 6
Counter Coil: CC Bit CC B 6
(C) Current value:
Word CN K, H 0 1
CN
Contact: LCS Bit LCS B 6
Long counter Coil: LCC Bit LCC B 6
(LC) Current value:
Double word LCN K, H 1 3
LCN
Data register (D) Word D K, H 0, 2, 4 1, 3
Link register (W) Word W K, H 0, 2, 4 1, 3
Link special register (SW) Word SW K, H 0, 2, 4 1, 3
System device
Special relay (SM) Bit SM B 6
Special register (SD) Word SD K, H 0, 2, 4 1, 3
Module access device (U\G)
Module access device (G) Word G K, H 0, 2, 4 1, 3
Index register
Index register (Z) Word Z K, H 0, 2, 4 1, 3
Long index register (LZ) Double word LZ K, H 2 3
File register
File register (R) Word R K, H 0, 2, 4 1, 3
79
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Update interval
The update interval of the user Web page is set with the HTML variable updateInterval.
This update interval is applied to all the user Web objects.
The message display language is set with the HTML variable dspLanguage.
This section explains the variable setting and the message display language.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- Set the title. -->
<title>Sample</title>
<link href="./css/UserWebStyle.css" rel="stylesheet" media="all" />
<!-- Reading the library JavaScript (Change the path to match the storage location.) -->
<script src="./FUserWebLib.js"></script>
<!-- Write the proprietary JavaScript from this point. -->
<!-- Write the user JavaScript here. -->
<script>
var updateInterval = 5; Update interval
var dspLanguage = 'en-US'; Message display language
</script>
</head>
80
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
5.3 Table
WITH CGI
CREATING A DEVICE MONITOR WINDOW
u Creation example
Direction: Horizontal
Row count: Two
Data count: Eight
Object design
Caution When the data format is set to single-precision real number, the data number base is changed to decimal.
7
REFERENCES
uHTML (JavaScript) structure
Create the HTML document for specifying the display devices consecutively as shown below with the number of rows or columns
of the devices to display.
X0 X1 X2 X3 X4 X5 X6 X7 X0 X1 X2 X3 X4 X5 X6 X7
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
81
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
uList of parameters
• Vertical b direction: 0
b devValBkCol a devValCol
C yPos
b devNamBkCol a devNamCol
C xPos devNamWidth
b b devValWidth
b blkSize
• Horizontal b direction: 1
b blkSize
Object 001 Object 002 Object 003 Object 004 Object 005 a dsp (item name)
7
1000 900 800 700 600 a name (device setting)
REFERENCES
In the above list of parameters, dev sets the table item name and device.
The settings in JavaScript are split into dsp:, name:, base:, and format:.
The value of the specified device (example: the values of X1 to X4) can be displayed.
In the following example, 'X' is the device classification and the sequence number (1 to 4) starting with the
variable “i” set with a for statement is the device number.
82
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
Value Description
K Decimal
H Hexadecimal
B Binary
WITH CGI
CREATING A DEVICE MONITOR WINDOW
u Data format … format:
REFERENCES
X0 X1 X2 X3
1 0 0 1
83
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
6
u Cell color specification … devNamBkCol: devValBkCol:
WITH CGI
CREATING A DEVICE MONITOR WINDOW
7
u How to view Web browser coordinates
REFERENCES
100 X0 X1 X2 X3 X4 X5 X6 X7
200 Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
300
Y-axis (unit: pixel)
400
500
600
700
800
84
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
Write all the required parameters. If a required parameter is not written or if a setting value is outside of its
Caution
range, an error occurs.
6
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Line No. JavaScript Explanation
The lines within a for statement (from its start to its end) are executed
repeatedly. In the statement on the left, “i” is used as the variable for
counting the number of repetitions. The () part is composed of three
statements: the default value of the variable for the number of repetitions,
the end condition of the for statement, and the calculation for changing the
3 for(var i = 0; i < 8; i++){
number of repetitions.
The calculation for changing the number of repetitions is “i++”, so the
variable is increased by one each time the contents of the for statement are
executed until the for statement ends.
Write the part in the () so that the range matches the input device number. The
number of data items in the table is set with blkSize. Match i to that value + 1.
7
4 temp.push({ Device name setting start
REFERENCES
Name to display for the table item
5 dsp: 'X' + i, You can write any name such as 'Input'. The example on the left displays X0
to X7.
Device specification
6 name: 'X' + i, Specify the device number with device classification “+i”. Set the PLC device
name.
Device data number Setting value Description
7 base: 'B',
base B Binary
Device specification
14 name: 'Y' + i, Specify the device number with device classification + i. Set the PLC device
name.
85
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
24 devNamCol: 'white',
example
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Device name cell Background color: Specified with a color code (RGB
25 devNamBkCol: '#808080', color specification value) in this example
and size
26 devNamWidth: 100, Cell width (in pixels)
27 devNamHeight: 40, Cell height (in pixels)
Character color: Specified with a color name in this
28 devValCol: 'blue',
example
Background color: Specified with a color name in
29 devValBkCol: 'white',
this example
Device value cell color
30 devValWidth: 80, specification and size Cell width (in pixels)
31 devValHeight: 50, Cell height (in pixels)
Line color: Specified with a color name in this
32 lnCol: 'blue',
example
33 xPos: 20, Display starting X-coordinate (in pixels)
34 yPos: 40 position Y-coordinate (in pixels)
86
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
5.4 Graphs
WITH CGI
CREATING A DEVICE MONITOR WINDOW
u Creation example
Direction: Vertical
Object design
REFERENCES
Display device specification
Execution Parameters
Level display settings
87
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
uList of parameters
• Vertical b direction: 0
b levWidth
d yPos
b upperVal
b bkCol
6 b upperAlmVal b almLnCol
WITH CGI
CREATING A DEVICE MONITOR WINDOW
b upperCol
b levLength
b levCol
b lowerAlmVal
b lowerVal b lowerCol
d xPos c devValWidth
7 • Horizontal b direction: 1
REFERENCES
b levLength
b levWidth
123
a Device settings
Value Description
0 16-bit signed (when omitted)
1 16-bit unsigned
2 32-bit signed
3 32-bit unsigned
4 Single-precision real number
88
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
Script Description
direction: 0 Vertical (when omitted)
direction: 1 Horizontal
6
u Upper/lower limit value … upperVal: lowerVal:
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Script Description
upperVal: Upper limit value
lowerVal: Lower limit value
Script Description
upperAlmVal: Upper limit of alarm value
lowerAlmVal: Lower limit of alarm value
REFERENCES
123 123
123
89
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Display example:
The current value is within the upper
and lower limits of the alarm value.
Display example:
The current value is less than the
lower limit of the alarm value.
7
u Size specification … levLength: levWidth
REFERENCES
90
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Ex. (xPos, yPos) = (550, 150)
100
200
300
Y-axis (unit: pixel)
400
500
600
7
700
REFERENCES
800
91
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Write all the required parameters. If a required parameter is not written or if a setting value is outside of its
Caution
range, an error occurs.
6
Line No. JavaScript Explanation
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Device specification
3 devName: 'D0', Specify the device number with device classification + i (set the PLC device
name).
Display
4 direction: 0, 0: Vertical (when omitted) 1: Horizontal
direction
5 levCol: 'mediumblue', Level display color: Specified with a color name in this example
6 upperCol: 'red', Upper limit of alarm value color: Specified with a color name in this example
Lower limit of alarm value color: Specified with a color code (RGB value) in
7 lowerCol: '#00FF00',
this example
8 bkCol: 'white', Background color: Specified with a color name in this example
7 Upper limit value: Range of values that can be handled with the specified
9 upperVal: 32767,
device
REFERENCES
Lower limit value: Range of values that can be handled with the specified
10 lowerVal: -32768,
device
Upper limit of alarm value: Range of values that can be handled with the
11 upperAlmVal: 20000,
specified device
Parameters
Lower limit of alarm value: Range of values that can be handled with the
12 lowerAlmVal: -20000,
specified device
Alarm value
13 dspAlmLn: 1, 0: Do not display. 1: Display (when omitted).
line display
14 almLnCol: 'black', Line color of alarm value: Specified with a color name in this example
15 levLength: 400, Level length: Positive real number (in pixels)
16 levWidth: 150, Level width: Positive real number (in pixels)
Current value
17 dspVal: 1, 0: Do not display. 1: Display (when omitted).
display
0: 16-bit signed (when omitted) 3: 32-bit unsigned
Device data
18 valFormat: 0, 1: 16-bit unsigned 4: Single-precision real number
format
2: 32-bit signed
19 devValCol: 'white', Character color of current value
20 devValBkCol: 'black', Background color of current value
21 devValWidth: 150, Cell width of current value (in pixels)
22 devValHeight: 50, Cell height of current value (in pixels)
23 xPos: 700, Display X-coordinate (in pixels)
starting
24 yPos: 250, position Y-coordinate (in pixels)
92
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
WITH CGI
CREATING A DEVICE MONITOR WINDOW
u Operation
REFERENCES
(2) An update interval portion is outside the
display range.
Number of records (pointNum)
Old New
(2) (1)
Object design
• The numeric values that can be handled with the historical graph object are fixed to decimal values.
Restriction
• If a state in which the communication load is high continues, device values may be lost.
Second line
Third line
93
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
uList of parameters
b upperMargin
d upper
6
b grHeight: b xLine
WITH CGI
CREATING A DEVICE MONITOR WINDOW
d lower
b lowerMargin
c xPos b yLine
b grWidth
b pointNum
a Device settings
Setting
Script Description
range
Line count
grElmNum: 1 to 32
setting
Setting
Script Description 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
range
Number of data
points along the
pointNum: 5 to 100
horizontal axis
of the line graph
Ex. pointNum: 21
94
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
32767 6
WITH CGI
CREATING A DEVICE MONITOR WINDOW
-32768
2019-1-15 9:45:32 2019-1-15 9:45:52
REFERENCES
pointNum: 21
5 5 5 5 Vertical axes are displayed as
yLine
12345123451234512345 shown below in the Web browser.
Ex. xLine: 9
1
2
3
4
5
6
7
8
9
95
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Script Description
lnCol: Graph line color
dspCol: Character color
grBkCol: Graph background color
6 32767 32767
WITH CGI
CREATING A DEVICE MONITOR WINDOW
-32768 -32768
2019-1-15 9:45:32 2019-1-15 9:45:52 2019-1-15 9:45:32 2019-1-15 9:45:52
100
200
300
Y-axis (unit: pixel)
400
500
600
700
800
96
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
Write all the required parameters. If a required parameter is not written or if a setting value is outside of its
Caution
range, an error occurs.
WITH CGI
CREATING A DEVICE MONITOR WINDOW
1
2 temp = [];,
3 num = 2; Number of graph elements, setting range: 1 to 32
4 temp.push({ Specification of the first line
5 devName: 'D0', Device name: Device classification + device number
6 lnCol: 'red', Graph line color: Specified with a color name in this example
7 });
8 temp.push({ Specification of the second line
9 devName: 'D1', Device name: Device classification + device number
10 lnCol: 'blue', Graph line color: Specified with a color name in this example
11 });
Display device specification (lines 1 and 2)
12 hstGrpParam = {
13 xPos: 20, Display starting X-coordinate (in pixels)
14 yPos: 250, position Y-coordinate (in pixels)
Argument num sets the number of graph elements with num = 2 on line 7
15 grElmNum: num,
number 3.
REFERENCES
Value Description
16 devFormat: 0, Device data format
0 16-bit signed
The argument temp sets the device name and graph line color to a value
17 grElm: temp,
that does not exceed the value of num on line number 3.
18 grBkCol: '#F0F0F0', Graph background color: Specified with a color code in this example
19 dspCol: 'black', Character color: Specified with a color name in this example
20 pointNum: 20, Number of records
21 pointInt: 2,
22 upper: 32767, Upper limit value
23 lower: -32768, Lower limit value
24 xLine: 9, Number of horizontal-axis lines: 0 to 99
25 yLine: 5, Vertical-axis interval (number of records) at which to display lines: 0 to 99
26 grHeight: 380, Graph height (in pixels)
27 grWidth: 550, Graph width (in pixels)
Upper margin: Positive real number (in pixels; set to 0 when the parameter
28 upperMargin: 15,
is omitted)
Left margin: Positive real number (in pixels; set to 0 when the parameter is
29 leftMargin: 75,
omitted)
Lower margin: Positive real number (in pixels; set to 0 when the parameter
30 lowerMargin: 55,
is omitted)
Right margin: Positive real number (in pixels; set to 0 when the parameter is
31 rightMargin: 25
omitted)
32 } JavaScript parameter setting end
Execution
97
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
5.5 Image/Figure
u Creation example
Monitor device: D0
Number of images: Three (including the default
display image)
7 Object design
REFERENCES
• As a guideline, ensure that the total size of all the image files in a single window is 100 kbyte or less.
Restriction • If setting ranges overlap, the images of the setting range with the lower number are displayed. For example, if
the device value is within setting range 1 and setting range 2, the display will be that for setting range 1.
Execution
Image display object settings
Parameters
Default display image
(common)
Image (first)
Image (second)
Parameters
(separate)
Image (fifth)
uList of parameters
C xPos
b pictHeight
98
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
a Device settings
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Single-precision real
0 16-bit signed 4
number
1 16-bit unsigned 5 Not used
2 32-bit signed 6 Bit
3 32-bit unsigned
b Image settings
REFERENCES
Switch-to image count
rangeNum: Setting range: 1 to 5
setting
99
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
6
Ex. rangeNum: 2
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Default display
Image (first) range.low: -5000, range.high: 5000
Image (second) range.low: -10000, range.high: 10000
100
200
300
Y-axis (unit: pixel)
400
500
600
700
800
100
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
Write all the required parameters. If a required parameter is not written or if a setting value is outside of its
Caution
range, an error occurs.
WITH CGI
CREATING A DEVICE MONITOR WINDOW
1 // Image display object Write a comment.
Execution
Device specification
3 devName: 'D0',
Device classification + device number
Value Description
4 devFormat: 0, Device data format
0 16-bit signed
REFERENCES
the image Upper limit value of the device
12 high: 5000,
(first) values that display the image
13 picture: './img/sample1.png', Specify an image file.
14 },
15 {
Lower limit value of the device
16 low: -10000,
Settings for changing values that display the image
the image Upper limit value of the device
17 high: 10000,
(second) values that display the image
18 picture: './img/sample2.png', Specify an image file.
19 },
20 ],
21 xPos: 150, Display starting X-coordinate (in pixels)
22 yPos: 50, position Y-coordinate (in pixels)
23 });
101
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
6
WITH CGI
CREATING A DEVICE MONITOR WINDOW
u Creation example
Object design
• If setting ranges overlap, the images of the setting range with the lower number are displayed.
For example, if the device value is within setting range 1 and setting range 2, the display will be that for setting
Restriction
range 1.
7 • The device value is monitored at a fixed interval.
REFERENCES
uList of parameters
C xPos C xPos
b figHeight b figHeight
• Triangle
b figWidth b defCol
C yPos
C xPos
b figHeight
102
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
a Device settings
WITH CGI
CREATING A DEVICE MONITOR WINDOW
K Decimal
H Hexadecimal
B Binary
REFERENCES
u Device value range setting … range.low: range.high:
b Figure settings
u Shape... figType:
103
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Operation example
Centered on 0, an upper limit value and a lower limit value are set on, respectively, the positive side and
negative side.
7
JavaScript example (extract)
REFERENCES
When three change colors are set, the JavaScript is as shown below.
JavaScript Explanation
104
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
WITH CGI
CREATING A DEVICE MONITOR WINDOW
u How to view Web browser coordinates
Ex. (xPos, yPos) = (400, 400)
100
200
300
Y-axis (unit: pixel)
400
500
7
600
REFERENCES
700
800
105
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Write all the required parameters. If a required parameter is not written or if a setting value is outside of its
Caution
range, an error occurs.
Execution
12 -5000,
display the figure color
Upper limit value of the device values that
13 high: 5000, Change setting (first)
display the figure color
Display color when the value is within the
14 col: 'green',
upper and lower limit values
15 },
16 {
Lower limit value of the device values that
17 low: -10000,
display the figure color
Upper limit value of the device values that
18 high: 10000, Change setting (second)
display the figure color
Display color when the value is within the
19 col: 'blue',
upper and lower limit values
20 },
21 ], Specification end of the setting range to change
22 xPos: 300, X-coordinate (in pixels)
Display starting position
23 yPos: 730, Y-coordinate (in pixels)
24 }); JavaScript parameter setting end
106
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
WITH CGI
CREATING A DEVICE MONITOR WINDOW
u Creation example
O K
The character string within the button can be
changed.
Object design
REFERENCES
Usage declaration
Parameters Writing device specification
Execution
uList of parameters
b btnWidth b logOutBtn
C yPos
C xPos
O K b btnHeight:
b btnTxt
a Device settings
Value Description
K Decimal
H Hexadecimal
B Binary
107
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Specify the input value with a character string. (Enclose it in single quotation marks ['].)
Special Note
Example: wrVal: '1'
b Button design
class element
wrBtn: Used with Style Sheet selectors
name
Script Description
btnTxt: Text displayed on the button (A blank is displayed when this parameter is omitted.)
108
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
WITH CGI
CREATING A DEVICE MONITOR WINDOW
language:0 language:1 language:2
The title bar and button text in the dialog box shown above are displayed in the language set with the
language setting in Windows®. The windows shown above are from the Japanese version of Windows® 10.
REFERENCES
c Display starting coordinates setting
100
200
300
Y-axis (unit: pixel)
O K
400
NG
500
600
700
800
109
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Write all the required parameters. If a required parameter is not written or if a setting value is outside of its
Caution
range, an error occurs.
OK button
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Execution
Sets the write value to '1' (turns ON X0). Sets the input value with a character
6 wrVal :'1',
string. (Enclose it in single quotation marks ['].)
7 wrBtn :'write_btn', Style Sheet class element name
btnTxt :'OK', Sets the text displayed on the button to 'OK'.
7 8
btnWidth :150, Width (in pixels)
9
Button size
REFERENCES
NG button
Execution
Sets the write value to '0' (turns OFF X0). Sets the input value with a
21 wrVal :'0',
character string. (Enclose it in single quotation marks ['].)
22 wrBtn :'write_btn', Style Sheet class element name
23 btnTxt :'NG', Sets the text displayed on the button to 'NG'.
24 btnWidth :150, Width (in pixels)
Button size
25 btnHeight :50, Height (in pixels)
26 wrComfirm :1, Write confirmation message presence
27 language :0, Message language
28 xPos :700, Display starting X-coordinate (in pixels)
29 yPos :130, position Y-coordinate (in pixels)
30 } JavaScript parameter setting end
110
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
u Creation example
6
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Log Out
The character string within the button can be
changed.
Object design
• Only one logout button object can be used per Web page.
Restriction • Be sure to store the user login page (Log-in_User.html) on the SD memory card.
• If a parameter is not specified, the default style specified with the Style Sheet (UserWebStyle.css) is used.
7
REFERENCES
uHTML (JavaScript) structure
Parameters Display settings
Execution
uList of parameters
b btnWidth b logOutBtn
C yPos
C xPos
Log Out b btnHeight:
b btnTxt
Script Description
btnWidth: Width (in pixels)
Button size
btnHeigh Height (in pixels)
111
5
5. LEARNING THE FUNCTIONS OF OBJECTS THAT CAN BE DISPLAYED WITH JAVASCRIPT (JS)
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
100
200
300
Y-axis (unit: pixel)
400
500
7 600
Log Out
REFERENCES
700
800
Write all the required parameters. If a required parameter is not written or if a setting value is outside of its
Caution
range, an error occurs.
9 WSLogoutBtn(logoutBtnParam); Execution
112
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
The device reading and writing CGI objects shown below can be used in user Web pages.
6
Item CGI name Function Reference section
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Device reading CGI RdDevRnd.cgi Reads the current value of the specified device. 6.4
Device writing CGI WrDev.cgi Writes the setting value to the specified device. 6.5
Overview of CGI
A Web server system operates on the FX5 PLC when the Web server function is enabled with a GX Works3 parameter.
The mechanism of CGI is as follows: in response to access from a Web browser, a CGI program is executed within the Web server
in the PLC, and then the result is returned to the Web browser.
FX5 PLC
7
(1) Request
REFERENCES
CGI program
Send data to the CGI.
Web server
Execute the program. Web browser
system
(2) Response
Execution result
Return the result. Client
HTML file
113
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
What Is CGI? Overview and Functions of CGI Common Specifications Device Reading Web Page Creation Device Writing Web Page Creation
Functions of CGI
The device reading/writing CGI objects shown below can be used in user Web pages. There are two types of CGI objects: [those
for reading from devices] and [those for writing to devices]. You can use CGI to read/write values from/to devices by clicking
the read/write buttons.
Window example
CGI name RdDevRnd.cgi Device name Data type Value
Function Reads the current value of the specified device. D10 16-bit integer 1234
D11 32-bit integer 123456
M0 Bit 0
Read
Devices set with the HTML Constants set with the HTML
uOperation procedure
As an example, this section explains the procedure for changing D11 on line 2 to D20 and monitoring the devices.
7
REFERENCES
Device name Data type Value Device name Data type Value
D10 16-bit integer D10 16-bit integer 1234
D11 32-bit integer 32-bit integer 123456
M0 Bit M0 Bit 0
Read Read Click the Close button (×) to delete the
device name.
Device name Data type Value 6 Click Read to update the D20 monitor value.
D10 16-bit integer 1234 Device name Data type Value
D11 32-bit integer 123456 D10 16-bit integer 1234
M0 Bit 0 D20 32-bit integer 0
Read Select the device name to display the M0 Bit 0
Close button (×).
Read
Update and display the values of D20 (the device that was
changed), D10, and M0.
For Web page creation method of the device monitor using CGI parts, refer to the following.
• Specifications of the devices which can be used
Related Page 6.3 Common Specifications
• Procedure of device reading Web page creation
6.4 Device Reading Web Page Creation
114
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
Window example
CGI name WrDev.cgi Device name Data type Value
Function Writes the setting value to the specified device. D10 16-bit integer 3 Write
D11 32-bit integer 10 Write 6
M0 Bit 1 Write
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Devices set with the HTML Constants set with the HTML
uOperation procedure
As an example, this section explains the procedure for changing D11 on line 2 to D20 and writing 55 to D20.
1 Click (for example) the D11 cell. 5 Clear (for example) value 10.
Device name Data type Value Device name Data type Value
D10 16-bit integer 3 Write D10 16-bit integer 3 Write
D11 32-bit integer 10 Write D11 32-bit integer Write
M0 Bit 1 Write M0 Bit 1 Write
Select the device name to display the Close Click the Close button (×) to delete the value.
button (×).
7
REFERENCES
6 Enter 55.
2 Clear (for example) D11.
Device name Data type Value
Device name Data type Value D10 16-bit integer 3 Write
D10 16-bit integer 3 Write 32-bit integer 55 Write
32-bit integer 10 Write M0 Bit 1 Write
M0 Bit 1 Write
Click the Close button (×) to delete the
device name.
7 Click Write.
For Web page creation method of the device monitor using CGI parts, refer to the following.
• Specifications of the devices which can be used
Related Page 6.3 Common Specifications
• Procedure of device reading Web page creation
6.5 Device Writing Web Page Creation
115
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
What Is CGI? Overview and Functions of CGI Common Specifications Device Reading Web Page Creation Device Writing Web Page Creation
uDevice name
Displays the device that can be accessed with the device reading CGI/device writing CGI.
Classification Device
Bit device*1 X, Y, M, L, B, F, SB, S, TS, TC, STS, STC, CS, CC, LCS, LCC, SM
6 Word device*2 T (current value), ST (current value), C (current value), D, W, SW, SD, U\G, Z, R
WITH CGI
CREATING A DEVICE MONITOR WINDOW
uDevice size
The usable device size varies depending on the device. Specify device number notations separately using octal, decimal, or
hexadecimal depending on the device.
: Can be used with both the device reading CGI and the device writing CGI, ×: Cannot be used
Device size
Device Notation
Bit Word Double word
User devices
Input (X) Octal*1 × ×
Output (Y) Octal*1 × ×
7 Internal relay (M) Decimal × ×
Latch relay (L) Decimal × ×
REFERENCES
116
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
uDevice value
Use the notations shown below with the device values handled by CGI objects.
Value handling Handle device values with hexadecimal notation in the String format (as character strings).
Conversions made by When using octal, decimal, or real number values in a Web page, use JavaScript (FUserWebLib.js) to convert such
JavaScript values into hexadecimal.
It is not necessary to add “0x” at the start of the value. Zero padding is also unnecessary.
For example, to write the value “0x012F”, write “12F”.
In the same manner, the read value is displayed as “12F” without “0x” added at its start and without any zero 6
How to specify padding.
WITH CGI
CREATING A DEVICE MONITOR WINDOW
hexadecimal values
Alphabet characters in hexadecimal values are not case sensitive.
For example, to write the value “0x012F”, write “12F” or “12f”.
The alphabet characters in read values are displayed in uppercase.
REFERENCES
117
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
What Is CGI? Overview and Functions of CGI Common Specifications Device Reading Web Page Creation Device Writing Web Page Creation
Name Function
Device reading CGI Requests the reading of the current value of the specified device.
Item Description
Access method method=“POST”
Access destination information
/cgi/RdDevRnd.cgi
(URL)
uRequest specifications
The following table lists the parameters used by requests. Specify parameters with the query string format.
Specify DEV(n) and TYP(n) with sequence numbers. If these parameters are not specified with sequence numbers, an error will
occur.
Parameter Reference
Data type Description Setting range
name section
Hexadecimal character string Set this parameter so that the total number of devices specified
NUM string indicating the number of for reading and writing per Web page is 32 or less. Next page
7 reading devices (n: 1 to 20)
A character string containing 16 or less alphanumeric
REFERENCES
characters.
DEV1 string Device name 1 (Characters are not case sensitive. Indirect specification, bit 6.3
specification, digit specification, and index modification are not
possible.)
B: Bit
TYP1 string Device size 1 W: Word 6.3
D: Double word
…
DEV(n) string Device name n The same as parameter name [DEV1] given above 6.3
TYP(n) string Device size n The same as parameter name [TYP1] given above 6.3
The query string format is a format used to pass data (parameters) to a Web server.
Assign values to parameters by adding the string [¶meter name=value] to the end of a URL. To pass multiple
Terminology
parameters, connect the query strings with [&].
Example: http://www.melsec/iq-f¶m1=0¶m2="Sample"
118
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
• The maximum number of devices that can be used on a single Web page is 32
Read
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Read
Write
uResponse specifications
The following table lists the parameters used by responses. Response data is in JSON format.
7
REFERENCES
Parameter
Data type Description
name
RET string Value Execution result (hexadecimal character string) details
0000 Normal
0001 Not logged in
0005 Illegal referer
4005 Too many devices
4030 Illegal device classification
4031 Out of device range
4041 Error: Specified buffer memory number + specified number of items to transfer is outside of the
buffer memory area.
4043 Non-existent module specification error
4080 CGI parameter error
DATA string Hexadecimal character string of the read values (an array)
{
"RET" : "0",
"DATA" : [ In the message, the response on the left is transferred in the following format.
"100",
Normal {"RET":"0", "DATA":["100", … , "FABC"]}
…
119
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
What Is CGI? Overview and Functions of CGI Common Specifications Device Reading Web Page Creation Device Writing Web Page Creation
6
Device name Value Make a request with D: double word specified for the
WITH CGI
CREATING A DEVICE MONITOR WINDOW
7
REFERENCES
120
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
In the device reading CGI, the table is created with the <table> tag.
The <input> tag is used to set cell contents such as item names and the names of the devices to monitor.
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Read
Device name Data type Value Different colors are used to indicate what objects are
D10 32-bit integer created by the HTML.
SD0 16-bit integer
M0 Bit
Read
REFERENCES
HTML document
Form
<form id="devform" name="readdev" method="post">
For details on the form and table construction, refer to the following.
Related Page
7.2 HTML Tag References
121
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
What Is CGI? Overview and Functions of CGI Common Specifications Device Reading Web Page Creation Device Writing Web Page Creation
Use the following procedure to create the device reading Web page.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
6
<!DOCTYPE html>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<html xmlns="http://www.w3.org/1999/xhtml">
<meta charset="UTF-8">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- charset setting
Set the title. --> *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8">
<title>Device Reading CGI Sample</title>
<meta http-equiv="X-UA-Compatible"
<!-- Write the user JavaScript here. -->content="IE=edge"/>
WITH CGI
CREATING A DEVICE MONITOR WINDOW
STEP 2.
xhr.open('POST',
xhr.onreadystatechange "/cgi/RdDevRnd.cgi",
= FUNC; true);
7
var FUNC = function() { ReadDeviceRandomTbl_Response(xhr, devtblid); }; // Response analysis function setting
xhr.onreadystatechange = FUNC;
xhr.send(param);
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> Enter the File name (example: read-device.html).
<head>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8"> For the Encoding, select UTF-8, and then click
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- Set the title. -->
<title>Device Reading CGI Sample</title>
<!-- Write the user JavaScript here. -->
[Save].
<script>
// CGI request function
function ReadDeviceRandomTbl(devtblid) {
var devtblitem = document.getElementById(devtblid);
var i, devitem, typitem;
var tblrows = devtblitem.rows.length; If you specify a value other than UTF-8 for the
Point
var param;
// Setting the number of devices Encoding, the text may be garbled when the
param = "NUM=" + (tblrows - 1) + '&';
for( i=1; i < tblrows; i++ ) {
// Device name parameter setting
HTML is displayed in a Web browser.
devitem = document.getElementById(devtblitem.rows[i].cells[0].childNodes[0].id);
param += devitem.name + "=" + devitem.value + '&';
STEP 3.
var FUNC = function() { ReadDeviceRandomTbl_Response(xhr, devtblid); }; // Response analysis function setting
STEP 4. Store the created HTML file on an SD memory card, and then use the Web server
function of the PLC to display this file.
122
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
uSample HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- Set the title. -->
<title>Device Reading CGI Sample</title>
<!-- Write the user JavaScript here. -->
6
<script>
WITH CGI
CREATING A DEVICE MONITOR WINDOW
// CGI request function
function ReadDeviceRandomTbl(devtblid) {
var devtblitem = document.getElementById(devtblid);
var i, devitem, typitem;
var tblrows = devtblitem.rows.length;
var param;
REFERENCES
}
else if( "32-bit integer" == typitem.value ) {
param += typitem.name + "=" + 'D';
}
else {
param += typitem.name + "=" + 'Q';
}
if( i < (tblrows - 1)) param += '&';
}
// CGI request
xhr = new XMLHttpRequest();
xhr.open('POST', "/cgi/RdDevRnd.cgi", true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var FUNC = function() { ReadDeviceRandomTbl_Response(xhr, devtblid); }; // Response analysis function setting
xhr.onreadystatechange = FUNC;
xhr.send(param);
}
123
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
What Is CGI? Overview and Functions of CGI Common Specifications Device Reading Web Page Creation Device Writing Web Page Creation
if ( 200 != xhr.status ) {
// If the value is not "200 OK", display an error dialog box.
alert("HTTP STATUS ERROR=" + xhr.status );
return;
}
var i, dataitem;
var devtblitem = document.getElementById(devtblid);
var tblrows = devtblitem.rows.length; // Obtain the number of table rows (including the header).
var res = JSON.parse( xhr.response ); // JSON character string analysis and processing
124
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
Name Function
Device writing CGI Orders the writing of the specified value to the specified device.
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Item Description
Access method method=“POST”
Access destination information
/cgi/WrDev.cgi
(URL)
uRequest specifications
The following table lists the parameters used by requests. Specify parameters with the query string format.
Parameter Reference
Data type Description Setting range
name section
Set this to 1.
Number of devices to write to
NUM string (Set this parameter so that the total number of devices specified Next page
(1).
for reading and writing per Web page is 32 or less.)
A character string containing 10 or less alphanumeric
characters.
DEV1 string Device name (Characters are not case sensitive. Indirect specification, bit 6.3 7
specification, digit specification, and index modification are not
REFERENCES
possible.)
B: Bit
TYP1 string Device size W: Word 6.3
D: Double word
DATA1 string Write value Hexadecimal character string —
The query string format is a format used to pass data (parameters) to a Web server.
Assign values to parameters by adding the string [¶meter name=value] to the end of a URL. To pass multiple
Terminology
parameters, connect the query strings with [&].
Example: http://www.melsec/iq-f¶m1=0¶m2="Sample"
125
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
What Is CGI? Overview and Functions of CGI Common Specifications Device Reading Web Page Creation Device Writing Web Page Creation
• The maximum number of devices that can be used on a single Web page is 32
Read
6 D12
D13
16-bit integer
16-bit integer
5
Read
Write
uResponse specifications
7 The following table lists the parameters used by responses. Response data is in JSON format.
REFERENCES
Parameter
Data type Description
name
RET string Value Execution result (hexadecimal character string) details
0000 Normal
0002 No user rights (CGI was executed by a user without the permission or rights to write to devices.)
0001 Not logged in
0005 Illegal referer
4005 Too many devices
4030 Illegal device classification
4031 Out of device range
4041 Error: Specified buffer memory number + specified number of items to transfer is outside of the
buffer memory area.
4043 Non-existent module specification error
4080 CGI parameter error
DATA string Hexadecimal character string of the read values (an array) from the devices written to
{ In the message, the response on the left is transferred in the following format.
"RET" : "0",
"DATA" : [
Normal {"RET":"0","DATA":["100"]}
"100"
]
} Error {"RET":"4031"}
126
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Device name Value Make a request with D: double word specified for the
DATA1 “35a5b36f” device size.
REFERENCES
127
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
What Is CGI? Overview and Functions of CGI Common Specifications Device Reading Web Page Creation Device Writing Web Page Creation
In the device writing CGI, the table is created with the <table> tag.
The <input> tag is used to set cell contents such as item names and the names of the devices to monitor.
Device name Data type Value Different colors are used to indicate what objects
D10 32-bit integer 3 Write are created by the HTML.
HTML document
128
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
Use the following procedure to create the device writing Web page.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
6
<!DOCTYPE html>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<html xmlns="http://www.w3.org/1999/xhtml">
<meta charset="UTF-8">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- charset setting
Set the title. --> *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8">
<title>Device Writing CGI Sample</title>
<meta http-equiv="X-UA-Compatible"
<!-- Write the user JavaScript here. -->content="IE=edge"/>
WITH CGI
CREATING A DEVICE MONITOR WINDOW
<!-- Set the title. -->
<script>
<title>Device
functionWriting CGI Sample</title>
WriteDeviceBlockTbl(devtblid, row) {
<!-- Write thevar user JavaScript here. -->
dataitem;
<script> var xhr;
function
varWriteDeviceBlockTbl(devtblid, row) {
devtblitem = document.getElementById(devtblid);
var
// dataitem;
Setting the number of devices (fixed to 1)
var xhr;
param = 'NUM=1&';
var
// devtblitem
Device name =parameter
document.getElementById(devtblid);
setting
//
var Setting
devitem the= number of devices (fixed to 1)
document.getElementById(devtblitem.rows[row].cells[0].childNodes[0].id);
var param
param = 'NUM=1&';
+= 'DEV1=' + devitem.value + '&';
// Device name parameter setting
var
// devitem
Device size= parameter
document.getElementById(devtblitem.rows[row].cells[0].childNodes[0].id);
setting
param
var typitem += 'DEV1=' + devitem.value + '&';
= document.getElementById(devtblitem.rows[row].cells[1].childNodes[0].id);
if( 'Bit' == typitem.value ) {
// Device size+=
param parameter
'TYP1=' +setting
'B';
var
} typitem = document.getElementById(devtblitem.rows[row].cells[1].childNodes[0].id);
if(
else 'Bit'
if( == typitem.value
'16-bit integer' ==) {typitem.value) {
param += 'TYP1=' + 'B'; 'W';
}
else if( '16-bit
'32-bit integer' == typitem.value) {
param += 'TYP1=' + 'W'; 'D';
}
else if({ '32-bit integer' == typitem.value) {
param += 'TYP1=' + 'D'; 'Q';
}
else
param { += '&';
param += 'TYP1=' + 'Q';
}// Data parameter setting
param += '&'; = document.getElementById(devtblitem.rows[row].cells[2].childNodes[0].id);
var dataitem
param += 'DATA1=' + parseInt(dataitem.value).toString(16)
// Data parameter setting
var dataitem
// CGI request= document.getElementById(devtblitem.rows[row].cells[2].childNodes[0].id);
Details on the HTML are also included in the MELSEC iQ-F FX5 User's Manual (Ethernet Communication) [JY997D56201].
param
xhr = new += 'DATA1=' + parseInt(dataitem.value).toString(16)
XMLHttpRequest();
xhr.open('POST', "/cgi/WrDev.cgi", true);
// CGI request
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr FUNC
var = new =XMLHttpRequest();
function() { WriteDeviceBlockTbl_Response(xhr, typitem, dataitem); }; // Response analysis function setting
STEP 2.
xhr.open('POST',
xhr.onreadystatechange "/cgi/WrDev.cgi",
= FUNC; true);
7
xhr.onreadystatechange = FUNC;
xhr.send(param);
REFERENCES
Enter the File name (example: write-device.html).
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
For the Encoding, select UTF-8, and then click
<!-- Set the title. -->
<title>Device Writing CGI Sample</title>
<!-- Write the user JavaScript here. -->
[Save].
<script>
function WriteDeviceBlockTbl(devtblid, row) {
var dataitem;
var xhr;
var devtblitem = document.getElementById(devtblid);
// Setting the number of devices (fixed to 1)
var param = 'NUM=1&';
If you specify a value other than UTF-8 for the
// Device name parameter setting
var devitem = document.getElementById(devtblitem.rows[row].cells[0].childNodes[0].id);
param += 'DEV1=' + devitem.value + '&';
Point Encoding, the text may be garbled when the
// Device size parameter setting
HTML is displayed in a Web browser.
var typitem = document.getElementById(devtblitem.rows[row].cells[1].childNodes[0].id);
if( 'Bit' == typitem.value ) {
param += 'TYP1=' + 'B';
}
else if( '16-bit integer' == typitem.value) {
param += 'TYP1=' + 'W';
}
else if( '32-bit integer' == typitem.value) {
param += 'TYP1=' + 'D';
}
else {
param += 'TYP1=' + 'Q';
}
param += '&';
// CGI request
xhr = new XMLHttpRequest();
xhr.open('POST', "/cgi/WrDev.cgi", true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var FUNC = function() { WriteDeviceBlockTbl_Response(xhr, typitem, dataitem); }; // Response analysis function setting
xhr.onreadystatechange = FUNC;
STEP 3.
xhr.send(param);
STEP 4. Store the created HTML file on an SD memory card, and then use the Web server
function of the PLC to display this file.
129
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
What Is CGI? Overview and Functions of CGI Common Specifications Device Reading Web Page Creation Device Writing Web Page Creation
uSample HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- charset setting *Because the Web server setting is UTF-8, specify UTF-8.) -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- Set the title. -->
6 <title>Device Writing CGI Sample</title>
<!-- Write the user JavaScript here. -->
<script>
WITH CGI
CREATING A DEVICE MONITOR WINDOW
else {
param += 'TYP1=' + 'Q';
}
param += '&';
// CGI request
xhr = new XMLHttpRequest();
xhr.open('POST', "/cgi/WrDev.cgi", true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var FUNC = function() { WriteDeviceBlockTbl_Response(xhr, typitem, dataitem); }; // Response analysis function setting
xhr.onreadystatechange = FUNC;
xhr.send(param);
}
130
5
6. CREATING A DEVICE MONITOR WINDOW WITH CGI
WITH CGI
CREATING A DEVICE MONITOR WINDOW
if ( 200 != xhr.status ) {
// If the value is not "200 OK", display an error dialog box.
alert("HTTP STATUS ERROR=" + xhr.status );
return;
}
var value;
var res = JSON.parse( xhr.response ); // JSON character string analysis and processing
// Judgment of the result from the CGI
if( res.RET != "0000" ) {
// If an error has occurred, display an error dialog box.
alert("ERROR=" + res.RET);
}
else {
// If the result is normal, reflect the writing result values.
dataitem.value = parseInt(res.DATA[0],16);
alert("Writing complete");
}
}
</script>
7
</head>
REFERENCES
<body>
<form>
<table id="devtbl" class="devtbl" border="1">
<tr>
<th>Device name</th>
<th>Data type</th>
<th>Value</th>
</tr>
<tbody>
<tr>
<td><input type="text" id="DEV1" name="DEV1" class="input" value="D10"/></td>
<td><input type="text" id="TYP1" name="TYP1" class="input" value="16-bit integer"/></td>
<td><input type="text" id="DATA1" name="DATA1" class="input" value="3"/></td>
<td><input type="button" value="Write" class="input" onclick="WriteDeviceBlockTbl('devtbl',1)"/></td>
</tr>
<tr>
<td><input type="text" id="DEV2" name="DEV2" class="input" value="D11"/></td>
<td><input type="text" id="TYP2" name="TYP2" class="input" value="32-bit integer"/></td>
<td><input type="text" id="DATA2" name="DATA2" class="input" value="10"/></td>
<td><input type="button" value="Write" class="input" onclick="WriteDeviceBlockTbl('devtbl',2)"/></td>
</tr>
<tr>
<td><input type="text" id="DEV3" name="DEV3" class="input" value="M0"/></td>
<td><input type="text" id="TYP3" name="TYP3" class="input" value="Bit"/></td>
<td><input type="text" id="DATA3" name="DATA3" class="input" value="1"/></td>
<td><input type="button" value="Write" class="input" onclick="WriteDeviceBlockTbl('devtbl',3)"/></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
131
5
7. REFERENCES
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
This section provides a simple explanation of the functions of the main properties of Style Sheets.
For details on Style Sheets such as how to use them, refer to commercially available reference books.
List of Properties
• This section explains the operations of the properties used by the user Web page library file (UserWebStyle.css).
1 position:
element.
7 background-color: Element background color
Specifies the overlapping order
2 z-index: 8 border: Element border
of the element.
3 width: Element width 9 text-align: Text position specification
Explanation
HTML
<div class="parent">
<p>Element (1)</p>
Browser display
<p id="absolute">Element (2)</p>
</div>
Style Sheet
Element (2)
.parent {
Element (1)
padding: 20px;
position: relative;
/*Set the parent element to relative.*/}
#absolute {
position: absolute;
top: 0;
left: 0;
}
/*Decorations are omitted.*/
132
5
7. REFERENCES
Value Description If you do not specify the z-index, the element will be covered
Specifies the overlapping order with integers with the elements that are written later in the code.
Integer value (zero is used as the reference, and the larger
the value, the higher up the object is). Browser display
HTML Second 6
WITH CGI
CREATING A DEVICE MONITOR WINDOW
<div id="example"> Third
<p class="one">First</p>
<p class="two">Second</p>
<p class="three">Third</p>
</div>
Style Sheet
REFERENCES
.two { z-index: 20; left: 20px; top: 20px; }
.three { z-index: 10; left: 40px; top: 40px; }
width
HTML
133
5
7. REFERENCES
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
margin-left
padding-left
margin-right
padding-right
u No. 7 [background-color:] … Element background Element contents
color
padding-bottom
6
background-color margin-bottom
WITH CGI
CREATING A DEVICE MONITOR WINDOW
Value Description
none No border (default value) solid double
hidden No border
solid Solid line (one line)
double Double line (two lines)
groove Concave line
ridge Convex line
groove ridge
Interior concave line (shadow on the upper-
inset
left part)
7 outset
Interior convex line (shadow on the lower-right
part)
inset outset
REFERENCES
Line thickness
Value Description
left Left-aligned (default value)
center Centered
right Right-aligned
HTML
Value Description
normal Standard thickness
bold General thickness of bold text
lighter Slightly thinner compared to bold text
bolder Slightly thicker compared to bold text
134
5
7. REFERENCES
WITH CGI
CREATING A DEVICE MONITOR WINDOW
cell Cell selection
help Help
The cursor shape varies depending on the OS of the terminal that displays the user Web page.
This section explains the operations of the properties of the Style Sheet of the “Menu” button used in “3. USING CUSTOMIZATION TO
EASILY CREATE A USER WEB PAGE”.
REFERENCES
of the Web browser
HTML
123 22500
• When set to position: absolute (the setting used in this guide) • When set to position: relative
top: ***px;
Menu Menu
135
5
7. REFERENCES
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
u No. B [left:] … Coordinate position from the left side of the Web browser
Menu
6
WITH CGI
CREATING A DEVICE MONITOR WINDOW
u No. C [top:] … Coordinate position from the top of the Web browser
top: 550 px;
7
Menu
REFERENCES
136
5
7. REFERENCES
You can use tags (text enclosed in the less-than (<) and greater-than (>) signs) to specify a variety of items including text and
image displays.
Some tags are used in a nested manner and some are used in a stand-alone manner.
List of Tags
This section provides a simple explanation of the functions of the tags used in this guide. 6
Tags that are not used in the user Web page library file (index.html) but are used in “3. USING CUSTOMIZATION TO EASILY CREATE A
WITH CGI
CREATING A DEVICE MONITOR WINDOW
USER WEB PAGE” are included.
REFERENCES
HTML Definition
137
5
7. REFERENCES
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
uText
Tag
HTML document Web browser display
Function Start End
uFont
Tag
HTML document Web browser display
Function Start End
Italic <i> </i> <i>Display line one. </i> Display line one.
7 Image
REFERENCES
Tag
HTML document Web browser display
Function Start End
138
5
7. REFERENCES
Reference
This section provides an explanation using an image file (sample0.png) in the user Web page library as an example.
STEP 1. Create a new image and save that file (example: sample0.gif) to the personal computer.
WITH CGI
CREATING A DEVICE MONITOR WINDOW
STEP 3. Right-click the displayed image and display its properties.
When displaying the image with a 1/1 ratio, enter the size displayed next to Properties 7
Dimensions: (in pixels).
REFERENCES
uSetting example General
sample0.png
width="30"
height="30"
Protocol: File Protocol
For example, if you change 30 pixels to 15 pixels, the displayed image will be Type: Unusable
Dimensions: 30 × 30 pixels
Created: 1/10/2019
Modified: 3/14/2018
OK Cancel Apply
STEP 4. Add the HTML as shown below between the <body> and </body> tags of the HTML
document.
uSetting example
src="./img/sample0.png"
uHTML
139
5
7. REFERENCES
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
Link
Tag
HTML document Web browser display
Function Start End
The link is indicated with blue, underlined text.
<a href="historical.html">2. Temperature
Link <a> </a>
Change Graph</a> 2. Temperature Change Graph
6
HTML Browser display
WITH CGI
CREATING A DEVICE MONITOR WINDOW
http://192.168.1.10 File
Title
Edit View Favorites Tools Help
140
5
7. REFERENCES
Table
Tag
HTML document Web browser display
Function Start End
Enclose the entire table in the <table> and </table>
tags.
<table>
Table <table> </table> Device name
</table> Device name
WITH CGI
CREATING A DEVICE MONITOR WINDOW
<tr> </tr> <tr><td>Device one</td><td>Device two</td></tr> Device Device
row
</table> one two
For each row created with the <th> and </th> tags,
the text is emphasized.
<table border="1">
Table
<th> </th> <tr><th>Device name</th><th>Production count</th></tr>
heading Device Production
</table>
name count
List of attributes 7
REFERENCES
Only some of the attributes are listed in this guide.
Attributes that are not set are handled as zero.
colspan="1"
A B C
Device
Column-joining name
(horizontal direction)
colspan <td colspan="number of cells to join">
specification colspan="3"
attribute
Device name
rowspan="1" rowspan="3"
Row-joining 1 Device
(vertical direction) name
rowspan <td rowspan="number of cells to join"> Device
specification
2 name
attribute
3
141
5
7. REFERENCES
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
width
Cell width width
Text alignment
(left-aligned)
left <td align="left"> Device name
(td tag default
value)
Horizontal
Text alignment
(center)
center <td align="center"> Device name
(th tag default
value)
Text alignment
right <td align="right"> Device name
(right-aligned)
7
REFERENCES
Device name
Text alignment
top <td valign="top">
(top-aligned)
Vertical
Text alignment
(center) middle <td valign="middle"> Device name
(Default value)
Text alignment
bottom <td valign="bottom">
(bottom-aligned)
Device name
uHTML
<table border="1">
</table>
142
5
7. REFERENCES
16 colors (basic colors) Web-safe colors, 216 colors Web color table, 147 colors
WITH CGI
CREATING A DEVICE MONITOR WINDOW
black #000000
silver #c0c0c0
maroon #800000
purple #800080
green #008000
olive #808000
navy #000080
teal #008080
gray #808080
white #ffffff
red #ff0000
fuchsia #ff00ff 7
lime #00ff00
REFERENCES
yellow #ffff00
blue #0000ff
aqua #00ffff
143
5
7. REFERENCES
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
16 colors (basic colors) Web-safe colors, 216 colors Web color table, 147 colors
Web-safe colors is an assembly of 216 colors defined with red, green, and blue each split into 6 levels (6 × 6 × 6). The advantage
of using a color scheme with web-safe colors is that while the range is limited to 216 colors, nearly the same colors can be
reproduced without being greatly influenced by the performance of the computer.
Hex Code Hex Code Hex Code Hex Code Hex Code Hex Code
6 Color
#RRGGBB
Color
#RRGGBB
Color
#RRGGBB
Color
#RRGGBB
Color
#RRGGBB
Color
#RRGGBB
WITH CGI
CREATING A DEVICE MONITOR WINDOW
144
5
7. REFERENCES
16 colors (basic colors) Web-safe colors, 216 colors Web color table, 147 colors
WITH CGI
CREATING A DEVICE MONITOR WINDOW
lightcoral #F08080 lightcyan #E0FFFF
REFERENCES
lightyellow #FFFFE0 teal #008080
145
5
7. REFERENCES
CAN BE DISPLAYED WITH JAVASCRIPT (JS)
LEARNING THE FUNCTIONS OF OBJECTS THAT
16 colors (basic colors) Web-safe colors, 216 colors Web color table, 147 colors
honeydew #f0fff0
mintcream #f5fffa
azure #f0ffff
aliceblue #f0f8ff
ghostwhite #f8f8ff
whitesmoke #f5f5f5
seashell #fff5ee
beige #f5f5dc
oldlace #fdf5e6
floralwhite #fffaf0
ivory #fffff0
antiquewhite #faebd7
linen #faf0e6
lavenderblush #fff0f5
mistyrose #ffe4e1
gainsboro #dcdcdc
lightgray #d3d3d3
silver #c0c0c0
darkgray #a9a9a9
gray #808080
dimgray #696969
lightslategray #778899
slategray #708090
darkslategray #2f4f4f
black #000000
146
WARRANTY
Please confirm the following product warranty details before using this product.
• “WARRANTY” in MELSEC iQ-F FX5U User's Manual (Hardware) Manual number: JY997D55301
• “WARRANTY” in MELSEC iQ-F FX5UC User's Manual (Hardware) Manual number: JY997D61401
SAFETY GUIDELINES
• To ensure proper use of the product described in this guide, be sure to read the manuals of the product before use.
• This product has been manufactured as a general-purpose part for general industries, and has not been designed or
manufactured to be incorporated in a device or system used for purposes related to human life.
• Before using the product for special purposes such as nuclear power, electric power, aerospace, medicine, or passenger
movement vehicles, consult Mitsubishi Electric representative.
• This product has been manufactured under strict quality control. However, when installing the product where major accidents
or losses could occur if the product fails, install appropriate backup or failsafe functions in the system
• For the precautions concerning design, wiring, and others, read SAFETY PRECAUTIONS provided in the relevant manuals.
TRADEMARKS
Microsoft, Windows, and Internet Explorer are either registered trademarks or trademarks of Microsoft Corporation in the United
States and/or other countries.
Google Chrome is either a registered trademark or trademark of Google Inc.
The SD and SDHC logos are either registered trademarks or trademarks of SD-3C, LLC.
IOS (iOS) is either a registered trademark or trademark of Cisco Systems, Inc. and/or its affiliates in the United States and/or other
countries, and iOS is used under license by Apple Inc.
Ethernet is a registered trademark of Fuji Xerox Co., Ltd. in Japan.
Oracle and JavaScript are registered trademarks of Oracle and/or its affiliates in the United States and/or other countries.
The company names, system names and product names mentioned in this guide are either registered trademarks or trademarks
of their respective companies.
In some cases, trademark symbols such as ‘™’ or ‘®’ are not specified in this guide.
REVISIONS
* The document number is given in the bottom-left corner of the back cover of this guide.
Revision date Document number Description
September 2019 L(NA)08645ENG-A First edition
This guide confers no industrial property rights or any rights of any other kind, nor does it confer any patent licenses. Mitsubishi Electric Corporation
cannot be held responsible for any problems involving industrial property rights that may occur as a result of using the contents noted in this guide.
Programmable Controller
MELSEC iQ-F Series
HEAD OFFICE: TOKYO BLDG., 2-7-3, MARUNOUCHI, CHIYODA-KU, TOKYO 100-8310, JAPAN
http://Global.MitsubishiElectric.com