显示警告框,其中包含文本字段

我是jquery的新手。 每当页面加载时,我想在其中显示带有TextBox字段的Alert Box。 像这样的东西:

Enter Your Username: //Title ___________________ //TextBox field (value will be stored in var for later use) OK //Button 

我知道

 var username = "username"; //already entered message alert(username); 

如何实现上述Alert Box? 我应该手动编码吗?
jQuery给出一个例子是可取的。 我正在尝试为我的聊天应用程序执行此操作,其中需要在聊天中显示用户名。 我搜索了很多,但找不到与asp.net和jquery有关的任何有用的东西。

只需使用旧的JavaScript:

 var text = prompt("prompt", "textbox's intial text"); 

现场演示

在jQuery中给出一个例子是可取的。

jQuery Impromptu提供了一个美观的JavaScript Prompt,它同样易于调用JavaScripts window.prompt方法:

 //Simple Prompt $.prompt('Example 1'); //Opacity of the modal $.prompt('Example 3',{ opacity: 0.2 }); //Adding Callbacks function mycallbackfunc(e,v,m,f){ alert('i clicked ' + v); } $.prompt('Example 8',{ callback: mycallbackfunc }); 

您可以使用JQueryUI对话框在对话框中显示表单。

“我想在其中显示一个带有TextBox字段的Alert Box,”。 文本字段的警报框根本不可能..(从我学到的东西到现在)….你可以使用其他jquery插件,如对话框

http://jqueryui.com/dialog/

做同样的..

或使用提示的经典方式

 var name=prompt("Please enter your name","Harry Potter"); 

试试这个:

 $(document).ready(function(){ var msg = window.prompt("Write your name", "Name"); alert(msg); });​