It sounds more like a JavaScript question.
All this will be much easier to make if you use some framework like jQuery: it will let you access easily to the DOM from your javascript code.
See for instance http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery for an official tutorial to easily manipulate the DOM of your page.
Here is an extract from this page:
We start with an empty html page:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
// we will add our javascript code here
</script>
</head>
<body>
<!-- we will add our HTML content here -->
</body>
</html>
This page just loads the jquery.js library (make sure the URL points
to where you stored your copy of jquery! This example assumes that you
store it in the same directory as this example file). Two comments
indicate where we will expand this template with code.
As almost everything we do when using jQuery reads or manipulates the
document object model (DOM), we need to make sure that we start adding
events etc. as soon as the DOM is ready.
To do this, we register a ready event for the document.
$(document).ready(function() {
// do stuff when DOM is ready
});
Putting an alert into that function does not make much sense, as an
alert does not require the DOM to be loaded. So lets try something a
little more sophisticated: Show an alert when clicking a link.
Add the following to the <body>
:
<a href="">Link</a>
Now update the $(document).ready
handler:
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
Then you just add this JavaScript in the Delphi, C++ or C# code which generates it, as plain text. You'll have to insert the Google AdSense code to the main page in the $(document).ready
handler.