弹出一个html页面或窗口以显示响应

时间:2013-06-28 20:18:20

标签: javascript jquery

我收到服务器的回复,回复的文字格式为

  "<div class=\"esv\"><h2>John 3:16 <object type=\"application/x-shockwave-flash\"  data=\"http://www.esvapi.org/assets/play.swf?myUrl=hw%2F43003016\" width=\"40\" height=\"12\" class=\"audio\"><param name=\"movie\" value=\"http://www.esvapi.org/assets/play.swf?myUrl=hw%2F43003016\" /><param name=\"wmode\" value=\"transparent\" /></object></h2>\n<div class=\"esv-text\"><h3 id=\"p43003016.01-1\">For God So Loved the World</h3>\n<p id=\"p43003016.07-1\"><span class=\"verse-num woc\" id=\"v43003016-1\">16&nbsp;</span><span class=\"woc\">&#8220;For God so loved the world,<span class=\"footnote\">&nbsp;<a href=\"#f1\" id=\"b1\" title=\"Or 'For this is how God loved the world'\">[1]</a></span> that he gave his only Son, that whoever believes in him should not perish but have eternal life.</span>  (<a href=\"http://www.esv.org\" class=\"copyright\">ESV</a>)</p>\n</div>\n<div class=\"footnotes\">\n<h3>Footnotes</h3>\n<p><span class=\"footnote\"><a href=\"#b1\" id=\"f1\">[1]</a></span> <span class=\"footnote-ref\">3:16</
    span> Or <em>For this is how God loved the world</em>\n</p>\n</div>\n</div>"

html格式喜欢image

任何技能都可以在javascript或jquery中弹出此消息吗?

1 个答案:

答案 0 :(得分:2)

如果你想在屏幕中间看一个漂亮的弹出窗口(不是标准的javascript警告弹出窗口),那么......

对于上面的div,你可以

1)将其放置在屏幕中央(阅读http://www.jakpsatweb.cz/css/css-vertical-center-solution.html)您可能希望使用position: fixed;设置div的样式,具体取决于您的网站设置方式。同时设置z-index: 999;或其他一些高数字。

2)隐藏它。例如,在CSS集.esv {display: none}

3)使用jQuery / javascript,在你想要的任何事件发生时显示它

$("#somebutton").click(function(){
         $(".esv").show(); // will display the popup window
    } 

这是一个非常简化的模型。但是这些方面的东西可能就是你想要的东西 如果您希望每次都有不同的内容,那么您可以先将<div class="esv"></div>设为空。然后使用jQuery在show()之前插入您想要的任何内容。但是,您必须研究如何动态选择要插入的内容。

所以第3步可能如下所示:

 $("#somebutton").click(function(){
         $(".esv").html( /* whatever html you want to insert. */);
         $(".esv").show(); // will display the popup window
    } 
相关问题