Hello world/Grafici (browser)
Di seguito sono illustrati esempi di Hello world eseguiti su interfacce grafiche su browser.
{curl (Version)applet} Hello world
Versione minima, con nessun elemento HTML, ma è comunque correttamente funzionante. Inoltre, è un quine banale.
hello, world
Versione completa, con tag necessari ed alcuni opzionali.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>hello, world</title>
<hta:application id="objHTA"
applicationname="HelloHTA"
border="dialog"
borderstyle="normal"
caption="hello, world"
contextmenu="no"
icon="icon.ico"
maximizebutton="no"
minimizebutton="yes"
navigable="no"
scroll="no"
selection="no"
showintaskbar="yes"
singleinstance="yes"
sysmenu="yes"
version="1.0"
windowstate="normal" />
<style type="text/css">
div { font-family: "Courier New" }
</style>
<script type="text/javascript">
//<![CDATA[
window.onload = function() {
document.getElementById("HelloMessage").innerText = "hello, world";
}
//]]>
</script>
</head>
<body>
<div id="HelloMessage" />
</body>
</html>
Java applet funzionano in collegamento con HTML.
import java.applet.*;
import java.awt.*;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Hello World!", 100, 50);
}
}
Codice HTML per vedere l'Applet con un Browser.
<object classid="java:HelloWorld.class"
codetype="application/java-vm"
width="600" height="100">
</object>
JavaScript, alias ECMAScript
modifica<script type="text/javascript">
alert("Hello World!");
</script>
Oppure:
<script type="text/javascript">
document.write("Hello World!");
</script>
<script language="VBScript">
MsgBox "Hello World!"
</script>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<box align="center">
<label value="Hello World!" />
</box>
</window>
<?Mapping ClrNamespace="System" Assembly="mscorlib" XmlNamespace=" http://www.gotdotnet.com/team/dbox/mscorlib/System" ?>
<Object xmlns=" http://www.gotdotnet.com/team/dbox/mscorlib/System" xmlns:def="Definition" def:Class="MyApp.Hello">
<def:Code>
<![CDATA[
Shared Sub Main()
'{
System.Console.WriteLine("Hello World!")' ;
'}
End Sub
]]>
</def:Code>
</Object>