.cAlert{
position: absolute;
top: 10px;
left: 10px;
width: 200px;
height: auto;
background-color: #dcdcdc;
border-left: 1px #8a8a8a solid;
border-top: 1px #8a8a8a solid;
border-right: 1px #a6a6a6 solid;
border-bottom: 1px #a6a6a6 solid;
}
.cAlertHeader{
margin: 0;
padding: 3px;
border-bottom: 1px #8a8a8a solid;
background-color: #333333;
color: #fff;
font-weight: bold;
}
.cAlertContent{
background-color: #f9f9f9;
margin-top: 25px;
margin-bottom: 5px;
margin-left: 10px;
margin-right: 10px;
padding: 10px;
border-left: 1px #bcbcbc solid;
border-top: 1px #bcbcbc solid;
border-right: 1px #fff solid;
border-bottom: 1px #fff solid;
}
<html>
<head>
<style type="text/css">
.cAlert{
position: absolute;
top: 10px;
left: 10px;
width: 200px;
height: auto;
background-color: #dcdcdc;
border-left: 1px #8a8a8a solid;
border-top: 1px #8a8a8a solid;
border-right: 1px #a6a6a6 solid;
border-bottom: 1px #a6a6a6 solid;
}
.cAlertHeader{
margin: 0;
padding: 3px;
border-bottom: 1px #8a8a8a solid;
background-color: #333333;
color: #fff;
font-weight: bold;
}
.cAlertContent{
background-color: #f9f9f9;
margin-top: 25px;
margin-bottom: 5px;
margin-left: 10px;
margin-right: 10px;
padding: 10px;
border-left: 1px #bcbcbc solid;
border-top: 1px #bcbcbc solid;
border-right: 1px #fff solid;
border-bottom: 1px #fff solid;
}
</style>
<!--Load the jquery lib -->
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<!--Use jquery -->
<script type="text/javascript">
$(document).ready(function(){
$('#myLink').click(function(){
var header = $('<div />').addClass('cAlertHeader')
.text('Alert box!');
var content = $('<div />').addClass('cAlertContent')
.text('This box contains an alert message for the user!');
$('<div />').attr('id', 'myAlertBox')
.addClass('cAlert')
.append(header)
.append(content)
.appendTo('body');
});
});
</script>
</head>
<body>
<a href="#" id="myLink">Show alert!</a>
</body>
</html>
<script type="text/javascript">
function $('a').click(function(){
//Whatever...
});
function $('a').click(function(e){
//Whatever, but with an e object and all its props and meths
});
</script>
<html>
<head>
<style type="text/css">
.cAlert{
position: absolute;
/*top: 10px;*/
/*left: 10px;*/
z-index: 2;
width: 200px;
height: auto;
background-color: #dcdcdc;
border-left: 1px #8a8a8a solid;
border-top: 1px #8a8a8a solid;
border-right: 1px #a6a6a6 solid;
border-bottom: 1px #a6a6a6 solid;
}
.cAlertHeader{
margin: 0;
padding: 3px;
border-bottom: 1px #8a8a8a solid;
background-color: #333333;
color: #fff;
font-weight: bold;
}
.cAlertContent{
background-color: #f9f9f9;
margin-top: 25px;
margin-bottom: 5px;
margin-left: 10px;
margin-right: 10px;
padding: 10px;
border-left: 1px #bcbcbc solid;
border-top: 1px #bcbcbc solid;
border-right: 1px #fff solid;
border-bottom: 1px #fff solid;
}
</style>
<!--Load the jquery lib -->
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<!--Use jquery -->
<script type="text/javascript">
$(document).ready(function(){
$('#myLink').click(function(e){
var mouseFromLeft = e.pageX;
var mouseFromTop = e.pageY;
var header = $('<div />').addClass('cAlertHeader')
.text('Alert box!');
var content = $('<div />').addClass('cAlertContent')
.text('This box contains an alert message for the user!');
content.append($('<a />').attr({'href':'#', 'id':'closeLink'})
.html('<br /><br />close'));
$('<div />').attr('id', 'myAlertBox')
.addClass('cAlert')
.css({'top':mouseFromTop, 'left':mouseFromLeft})
.append(header)
.append(content)
.appendTo('body');
});
$('#closeLink').live('click', function(){
$('#myAlertBox').remove();
});
});
</script>
</head>
<body>
<a href="#" id="myLink">Show alert!</a>
</body>
</html>
<html>
<head>
<style type="text/css">
.cAlert{
position: absolute;
/*top: 10px;*/
/*left: 10px;*/
z-index: 2;
width: 200px;
height: auto;
background-color: #dcdcdc;
border-left: 1px #8a8a8a solid;
border-top: 1px #8a8a8a solid;
border-right: 1px #a6a6a6 solid;
border-bottom: 1px #a6a6a6 solid;
display: none;
}
.cAlertHeader{
margin: 0;
padding: 3px;
border-bottom: 1px #8a8a8a solid;
background-color: #333333;
color: #fff;
font-weight: bold;
}
.cAlertContent{
background-color: #f9f9f9;
margin-top: 25px;
margin-bottom: 5px;
margin-left: 10px;
margin-right: 10px;
padding: 10px;
border-left: 1px #bcbcbc solid;
border-top: 1px #bcbcbc solid;
border-right: 1px #fff solid;
border-bottom: 1px #fff solid;
}
</style>
<!--Load the jquery lib -->
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<!--Use jquery -->
<script type="text/javascript">
$(document).ready(function(){
$('.alertLink').hover(function(e){
var mouseFromLeft = e.pageX;
var mouseFromTop = e.pageY;
var content = new Object();
if($(this).text() == 'google.com'){
content.link = '<a href="http://www.google.com">http://www.google.com</a>';
content.type = "Search engine";
content.founder = "Larry Page and Sergey Brin";
}
else if($(this).text() == 'jquery.com'){
content.link = '<a href="http://www.jquery.com">http://www.jquery.com</a>';
content.type = 'Javascript library';
content.founder = 'John Resig';
}
else if($(this).text() == 'morkalork.com'){
content.link = '<a href="http://www.MorkaLork.com">http://www.MorkaLork.com</a>';
content.type = 'Programming tutorials';
content.founder = 'Magnus Ferm';
}
var header = $('<div />').addClass('cAlertHeader')
.text('Alert box!');
var content = $('<div />').addClass('cAlertContent')
.html("<p>Link: " + content.link + "</p><p>Type: " + content.type + "</p><p>Founder: " + content.founder + "</p>");
$('<div />').attr('id', 'myAlertBox')
.addClass('cAlert')
.css({'top':mouseFromTop, 'left':mouseFromLeft})
.append(header)
.append(content)
.appendTo('body');
$('#myAlertBox').fadeIn('slow');
}, function(){
$('#myAlertBox').remove();
});
});
</script>
</head>
<body>
<p>There are a lot of pages on the internet, <a href="#" class="alertLink">google.com</a> is one of them, <a href="#" class="alertLink">jquery.com</a> is another one!</p>
<p>If you don't have time to visit them all, make sure you don't miss <a href="#" class="alertLink">morkalork.com</a>!</p>
</body>
</html>
There are no comments on this article.
If you have any question or just want to leave a message, just fill out the form below!
Your e-mail will not be visible in your post, it is for validation reasons only