AJAX - The Complete Reference

(avery) #1

PART III


Chapter 10: Web Services and Beyond 525


<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Chapter 10: Socket Time</title>
<script type="text/javascript">

function createSWF()
{
var swfNode = "";
if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length)
swfNode = '<embed type="application/x-shockwave-flash" src=
"http://ajaxref.com/ch10/flash/ajaxtcrflash.swf" width="1" height="1"
id="flashbridge" name="flashbridge" />';
else {
swfNode = '<object id="flashbridge" classid=
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1" >';
swfNode += '<param name="movie" value=
"http://ajaxref.com/ch10/flash/ajaxtcrflash.swf" />';
swfNode += "</object>";
}
document.getElementById("flashHolder").innerHTML = swfNode;
}
function getSWF(movieName)
{
if (navigator.appName.indexOf("Microsoft")!= -1)
return window[movieName];
else
return document[movieName];
}

function printTime(str)
{
document.getElementById("responseOutput").innerHTML = str;
}
window.onload = function() {
createSWF();
document.getElementById("socketButton").onclick = function(){
getSWF("flashbridge").socket("", "7225",
"printTime");}
}
</script>
</head>
<body>
<form action="#">
<input type="button" value="Socket what time is it? " id="socketButton" />
</form>
<br /><br />
<div id="flashHolder"></div>
<div id="responseOutput"> </div>
</body>
</html>
Free download pdf