Let's say i have this code
<p id="test">
some content
<p>
<a href="#" id="test-link">Open</a>
Now i want -using javascript/jquery- to create a popup window, the window content is the content of test
paragraph, when test-link
is clicked.
How cou开发者_开发技巧ld this be done?
<a href="javascript:popup();" id="test-link">Open</a>
function popup()
{
var generator=window.open('','name','height=400,width=500');
generator.document.write('<html><head><title>Popup</title>');
generator.document.write($("#test").html());
generator.document.write('</body></html>');
generator.document.close();
}
You can do this using jQuery UI (dialog) (see examples in the reference documentation).
im using http://defunkt.github.com/facebox/ its nice.
Use jQuery UI dialog to show popup.
For your html:
$(function()
{
$("#test-link").click(function()
{
$("#test").dialog({ resizable: true,
modal: false, draggable: true
});
});
});
If you don't want to go for jQuery UI dialog then you can use ThickBox.
精彩评论