Main BLOGGER
Google
WWW THIS BLOG
Tuesday, September 11, 2007
 
dynamic generate javascript
1. The html
PollServer.html (from http://xcrc.ucvhost.com/demo/pollServer.html)

<META HTTP-EQUIV="Expires" CONTENT="0">
<title>My client</ title>

<script type="text/javascript">
var myscript = ' time2.asp';
var timer;

function reloadScript() {
var head = document.getElementsByTagName('head').item(0);
var old = document.getElementById('scriptId');
if (old) head.removeChild (old);

script = document.createElement('script');
//call the server side asp for the script source
script.src = myscript;
script.type = 'text/javascript';
script.defer = true;
script.id = 'scriptId';
//run the script
void(head.appendChild(script));
}

function poll(t){timer=setInterval('reloadScript()', t);}

</script>
</head>

<body>
<!-- place holder to display time -->
The server tells me: < span id="time"> </span><BR>< BR>
<a href="javascript: poll(2000)">Start Polling!</a>;
<a href="javascript:clearInterval(timer);">Stop polling</a>
</body>
</html>


2. the JSP (
http://xcrc.ucvhost.com/demo/time2.jsp )
will return a string like

document.getElementById('time').innerHTML = '\'The time on the server is: Tuesday, September 11, 2007 @ 10:24:47 AM\''; 


--
Pop (Pu Liu)

Wednesday, September 05, 2007
 
a link of google interview
http://www.nofluffjuststuff.com/blog/brian_pontarelli/2007/08/google_interviewing.html

--
Pop (Pu Liu)


Powered by Blogger

Google
WWW THIS BLOG