我有一个以下风格的div:高度:250px;滚动:auto;.我希望它在250像素后滚动,但根据其中的内容应该有高度.
例如,如果其中的内容是100px,那么div的高度应为100而不滚动.但是,如果高度超过250px,它应该显示滚动.
怎么办?
所以,我从使用Mechanize开始,显然我尝试的第一件事是猴子 - 犀牛级高JavaScript导航网站.
现在,我坚持的是提交表格.
通常我会使用Mechanize内置的submit()函数进行提交.
import mechanize
browser = mechanize.Browser()
browser.select_form(name = 'foo')
browser.form['bar'] = 'baz'
browser.submit()
Run Code Online (Sandbox Code Playgroud)
这样它就可以使用HTML表单中提供的提交按钮.
但是,我坚持使用的网站必须是不使用HTML提交按钮的网站...不,他们试图成为JavaScript大师,并通过JavaScript进行提交.
通常的submit()似乎不适用于此.
那么......有办法解决这个问题吗?
任何帮助表示赞赏.非常感谢!
- [编辑] -
我坚持使用的JavaScript函数:
function foo(bar, baz) {
var qux = document.forms["qux"];
qux.bar.value = bar.split("$").join(":");
qux.baz.value = baz;
qux.submit();
}
Run Code Online (Sandbox Code Playgroud)
我在Python中做了什么(以及什么不起作用):
def foo(browser, bar, baz):
qux = browser.select_form("qux")
browser.form[bar] = ":".join(bar.split("$"))
browser.form[baz] = baz
browser.submit()
Run Code Online (Sandbox Code Playgroud) 这是我从服务器返回的Json
{"ErrorCode":1005,"Message":"Username does not exist"}
Run Code Online (Sandbox Code Playgroud)
这是我的错误类
public class ErrorModel {
public int ErrorCode;
public String Message;
}
Run Code Online (Sandbox Code Playgroud)
这是我的转换代码.
public static ErrorModel GetError(String json) {
Gson gson = new Gson();
try
{
ErrorModel err = gson.fromJson(json, ErrorModel.class);
return err;
}
catch(JsonSyntaxException ex)
{
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
它总是抛出JsonSyntaxException.任何想法可能是我的问题吗?
编辑:根据要求,这里进一步阐述.
我的后端是一个ASP.NET MVC 2应用程序,充当rest API.后端不是问题,因为我的操作(甚至服务器错误)都返回Json(使用内置JsonResult).这是一个样本.
[HttpPost]
public JsonResult Authenticate(AuthenticateRequest request)
{
var authResult = mobileService.Authenticate(request.Username, request.Password, request.AdminPassword);
switch (authResult.Result)
{
//logic omitted for clarity
default:
return ExceptionResult(ErrorCode.InvalidCredentials, "Invalid username/password");
break; …Run Code Online (Sandbox Code Playgroud) 我假设我需要一个正则表达式?
我有一个邮政编码字段,邮政编码必须在芝加哥的城市范围内.幸运的是,所有的邮政编码都以606开头.所以我需要轮询输入以确保输入的邮政编码是5位数,并以数字606开头:
我的输入很基本:
<label for="dzip"><span class="red">♥ </span>Zip:</label>
<input name="attributes[address_zip]" id="dzip" type="text" size="30" class="required zip-code" />
Run Code Online (Sandbox Code Playgroud)
然后我的城市脚本很容易.我只需要将它应用于邮政编码:
jQuery.validator.addMethod("Chicago", function(value) {
return value == "Chicago";
}, '**Recipient must reside in Chicago City Limits**');
Run Code Online (Sandbox Code Playgroud)
如果我展示插件如何用于电话号码(美国),可能会有所帮助.基本上我需要把它翻译成拉链:
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
phone_number = phone_number.replace(/\s+/g, "");
return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid phone number");
Run Code Online (Sandbox Code Playgroud)
这部分的意思是什么?
phone_number.replace(/\s+/g, "")
Run Code Online (Sandbox Code Playgroud)
我直接从验证网站上的示例中删除了手机部分.
这里所有伟大(和快速)输入的最终答案是:
jQuery.validator.addMethod("zip-code", function(zip_code, element) {
zip_code = zip_code.replace(/\s+/g, "");
return this.optional(element) || zip_code.length == 5 && zip_code.match(^606[0-9]{2}$);
}, "Please specify a City …Run Code Online (Sandbox Code Playgroud) 使用简单的方法按钮放大和缩小UIView的最佳方法是什么.(EI
(IBAction)zoomin:(int)distance
{
method here
}
(IBAction)zoomout:(int)distance
{
and here
}
Run Code Online (Sandbox Code Playgroud) 可能重复:
与adb的连接已关闭,并且发生了严重错误
我目前正在尝试在最新版本的Eclipse中开发Android应用程序.当我尝试构建和运行时,会出现以下内容:
[2011-02-17 17:08:03 - <ProgramName>] The connection to adb is down, and a severe error has occured.
[2011-02-17 17:08:03 - <ProgramName>] You must restart adb and Eclipse.
[2011-02-17 17:08:03 - <ProgramName>] Please ensure that adb is correctly located at 'C:\<sdk-directory>s\platform-tools\adb.exe' and can be executed.
Run Code Online (Sandbox Code Playgroud)
现在,我已经更新了ADT插件,我有最新版本的Android SDK; 实际上,adb.exe位于platform-tools目录中并且可以执行.我尝试过在Google上找到的所有内容:
注意:我正在运行Windows 7.此外,我之前在Eclipse中测试过应用程序.自升级SDK以来,此错误对我来说是新的.
是否存在将JAX-RS和JAX-WS(或等效功能)组合到一个组合服务中的框架,库或技术,类似于在WCF中为同一服务使用两个端点(一个SOAP和一个REST)?
嗨我使用"heatmap.plus"在R中创建了一个热图,它显示在链接中
http://i.stack.imgur.com/hizBf.jpg
但我需要热图看起来像下面链接中显示的热图,它是从其他GUI软件创建的
http://i.stack.imgur.com/Y8Faj.png
如何在R中的每个热图元素中添加黑色边框
该函数normalize-space删除前导和尾随空格,并用单个空格替换空白字符序列.我怎么能只在XSLT 1.0单个空格替换一系列空白字符?例如"..x.y...\n\t..z."(为了便于阅读,用点替换的空格)应该成为".x.y.z.".
我目前对"使用(命名空间)"语句在C++中的工作方式感到困惑.
我有:
//somewhere in included headers
typedef unsigned int uint;
namespace mine {
typedef unsigned int uint;
}
namespace other {
using namespace mine;
void foobar () {
uint offender = i;
}
}
Run Code Online (Sandbox Code Playgroud)
结果(转述):
对'uint'的引用含糊不清.候选者是
typedef unsigned int uint
和
typedef unsigned int mine :: uint
同时,当我这样做的时候
namespace other {
using namespace mine;
using mine::uint;
void foobar () {
uint offender = i;
}
}
Run Code Online (Sandbox Code Playgroud)
一切正常."使用标识符 " 对我来说似乎很奇怪 更改其他typedef定义的可见性(隐藏全局定义?).有人能指出我用C++中的哪种规则管理跨命名空间的typedef解析?