jQuery.fn.center = function () { this.css("position","absolute"); this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px"); this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px"); return this; } function displayhelp(inTitle, inText) { var objTitle = $(inTitle); var objText = $(inText); var objReplace = $("<div id=\"div_helpContent\"><h3>" + inTitle + "</h3><p>" + inText + "</p></div>"); $("#div_helpContent").replaceWith(objReplace) $("#div_helpWindow").css( "display", "block" ); $("#div_helpWindow").center(); } //<div id=\"div_helpTitle\"><img src=\"closehelp.png\" class=\"closeHelp\" alt=\"Close\" /></div> $(document).ready( function() { $("body").append( "<div id=\"div_helpWindow\"><div id=\"div_helpContent\"><h3>Titel</h3><p>Text</p></div><div id=\"div_helpBottom\"><input type=\"button\" value=\"Schließen\" class=\"button closeHelp\" /></div></div>" ); $("#div_helpWindow").css( "display", "none" ); $("#div_helpWindow").center(); $("#div_helpWindow").find(".closeHelp").css( "cursor", "pointer" ); $("#div_helpWindow").find(".closeHelp").click( function() { $("#div_helpWindow").css( "display", "none" ); }); });