HTML正文“加载"在Chrome中无法使用 [英] Html body "onload" is not working in Chrome

查看:139
本文介绍了HTML正文“加载"在Chrome中无法使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用servlet和jsp编写了示例Web应用程序.按照下面的代码,动作网址应自动执行 根据加载".我已经在自己的servlet之一中编写了下面的代码,下面的"onload"形式起作用了 仅在Firefox和IE中有效,而在Chrome(41.0.2272.74 beta-m(64位))中无效.我已经看到了

I have written sample web application with servlets and jsp. As per the below code the action url should be executed automatically according to the "onload". I have written this below code in one of my servlet, The below "onload" form hits the path in action only in Firefox and IE but not in Chrome(41.0.2272.74 beta-m (64-bit)).I have seen the link Chrome - is not working but i did not get proper idea, I have my below code in the end of servelt. there is nothing to execute after this code in the servlet.

 out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> \n");
    out.write("<html><body onload=\"alert('alert has been fired');document.forms[0].submit()\">\n");
    out.write("<form method=\"POST\" action=\"" + actionUrl + "\">\n");
    out.write("<input type=\"hidden\" name=\"resourcePath\" value=\"" + callbackUrl + "\"/>\n");
    out.write("<input type=\"hidden\" name=\"locale\" value=\"" + locale + "\"/>\n");
    out.write("<input type=\"hidden\" name=\"rspjRequest\" value=\"" + true + "\"/>\n");
    out.write("</form>\n</body>\n</html>\n");
    out.close();

上述操作网址中是否有chrome保留的关键字?

Is there any reserved key words of chrome in the above action url?

推荐答案

经过一番调查,终于找到了解决我问题的方法.我忘记为Servlet中的响应设置内容类型.

After some investigation finally i got solution for my problem. I forgot to set the Content type for the response in the servlet.

response.setContentType("text/html; charset = UTF-8");

Chrome浏览器将使用上述行以html页面的形式显示响应.

Chrome browser will display response in the form of html page by using above line.

这篇关于HTML正文“加载"在Chrome中无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆