最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Open a popup windows with my own htmljavascript code - Stack Overflow

programmeradmin1浏览0评论

I'd like to open a popup window, but without given a link : just open it with some HTML and Javascript code (that I pass trought the function).

Tried with :

window.open($('.my_html').html(), "Booking", "width=950,height=680");

How can I do it?

I'd like to open a popup window, but without given a link : just open it with some HTML and Javascript code (that I pass trought the function).

Tried with :

window.open($('.my_html').html(), "Booking", "width=950,height=680");

How can I do it?

Share Improve this question edited Oct 26, 2011 at 8:03 markzzz asked Oct 26, 2011 at 7:58 markzzzmarkzzz 48.1k126 gold badges318 silver badges534 bronze badges 2
  • 2 Have you tried anything or would you like us to do your work for you? – Simon Commented Oct 26, 2011 at 8:02
  • Yeah of course. Added an example... – markzzz Commented Oct 26, 2011 at 8:03
Add a ment  | 

4 Answers 4

Reset to default 2
writeConsole('Hello from JavaScript!');
function writeConsole(content) {
 top.consoleRef=window.open('','myconsole','width=350,height=250');
 top.consoleRef.document.write(content)
 top.consoleRef.document.close()
}

Source

You can do it like this:

var popup = window.open(#mySettings#);

and then

popup.document.write('#myHTML#');
function openpopup(content){ 
    winpops=window.open('',"test","fullscreen=no,toolbar=yes,status=yes, " +
    "menubar=yes,scrollbars=yes,resizable=yes,directories=yes,location=yes, " +
    "width=500,height=400,left=100,top=100,screenX=100,screenY=100");
    winpops.document.write(content);
} 
openpopup('<h1>This is some test content</h1>');

You can call function on any event, and supply content you want to show.

do you have to use browser popups? They're annoying and can be blocked by ad-blockers.

Why not do it as modal windows instead? like this: http://www.sohtanaka./web-design/inline-modal-window-w-css-and-jquery/

or the jQuery plugin jqModal.

发布评论

评论列表(0)

  1. 暂无评论