<script type="text/javascript">
$(document).ready(function() {
$("a").click(function(event) {
alert("Thanks for visiting!");
});
});
</script>
<style>
div.iframe-link {
position: relative;
float: left;
width: 175px;
height: 205px;
margin: 0 1em 1em 0;
border: 3px solid blue;
}
a.iframe-link {
position: absolute;
top:0;
right: 0;
bottom: 0;
left: 0;
}
</style>
</head>
<body>
<a href="swedish.html">click link to populate container</a><br>
<!-- note: it populates the container at load currently ... I only want it to
populate after clicking the link -->
<div class="iframe-link">
<iframe src="swedish.html?style=sandbeach" style=" border-width:2 " width="175"
height="175" frameborder="2" scrolling="no"></iframe>
</div>
</body>
</html>
<script type=text/javascript> $(document).ready(function() { $(a).click(function(event) { alert(Thanks for visiting!); }); }); </script> <style> div.iframe-link
Share
You need to
return falsein your click handler.Also, in some browsers, that may not be enough -> you should also call
preventDefault().Here’s a working example: