Reputation: 1358
I am very new to java script, can anyone tell me how I can get a pop up with javascript on a button click.
I need to add some text and image to this popup.
Thanks
Upvotes: 0
Views: 208
Reputation: 14575
If you want a new window to open as a popup, you can use:
window.open('newpage.html');
This will open the file newpage.html
in a new window, that you can style however you like with HTML and CSS.
Edit:
If you want to do it inside the same window, I would recommend hiding a div and then showing it on click, like this:
You can use jQuery plugins to achieve this and much more for you, but as a learning exercise the above is very simple and doesn't require external libraries
Upvotes: 3
Reputation: 1078
The easiest way is using jQuery Dialog
and this is a sample: jQuery Dialog
Upvotes: 0
Reputation: 78525
The simplest method is to use the jQuery UI popup plugin. You will also need to include the jQuery library.
http://jqueryui.com/dialog/#modal-message
Javascript:
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
HTML:
<div id="dialog-message" title="Download complete">
<p>
<span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
Your files have downloaded successfully into the My Downloads folder.
</p>
<p>
Currently using <b>36% of your storage space</b>.
</p>
</div>
Upvotes: 1
Reputation: 1196
You can use:
alert('your text');
But if you need to customize the popup with images, backgrounds etc then you'd better get your hand on jQuery and study it.
There are many tutorials around, just google for them (or buy a good manual :)
Upvotes: 1