
Well, a "pop-up" is an action, so we need a language that handles actions. We will use JavaScript. JavaScript works great for this sort of thing.
There are two steps in creating this particular action:
Step One - Create the Function that directs the action
"A function will be executed by an event or by a call to the function."
Our JavaScript is "extra" information needed to make the page work, so we will be placing it in the "HEAD" section of the HTML. So it needs to go between the <head> and </head> tags
We also need to surround the JavaScript with the HTML "script" tags so that the browser knows that it is another language other than HTML, and what language it is.
Take a look at the code below:
<script type="text/javascript">
function open_win()
{
window.open('Flash/RE_Banner.html','RE','width=336, height=280')
}
</script>
The <script> tag has attributes describing the language the script is written in. It also has an </script> to let the browser know when the script ends
The function we declaired is called "open_win", but could be called, or named anything we like, as long as it's not already reserved.
Between the two "curly braces" {}, we have the actual instructions.
window.open will open a new window.
Between the "parenthesis" () is where we can pass some additional information about the window
The syntax looks like this: window.open(URL, page title, additional attributes)
Step Two - Create the Event that triggers the Function
"Events are actions that can be detected by JavaScript."
The next part will be in the "body" of the HTML page, so it belongs between the <body> and </body> tags
We will use an "anchor" tag, and apply our "trigger" to it. <a> and </a> are the HTML tags that create anchors, so our code will look something like this:
<a href="#" onclick="open_win()">new banner</a>
We just told the browser that when someone "clicks" the "anchor" to run the function called "open_win()".
That's it, you're done. As long as your syntax is correct, it should work in any browser.
-Dan
Recent Comments