const.jsp
资源名称:shihua.rar [点击查看]
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:2k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
JavaScript
- <%!
- public static String toHTMLString(String in){
- StringBuffer out = new StringBuffer();
- for (int i = 0; in != null && i < in.length(); i++) {
- char c = in.charAt(i);
- if (c == ''')
- out.append("'");
- else if (c == '"')
- out.append(""");
- else if (c == '<')
- out.append("<");
- else if (c == '>')
- out.append(">");
- else if (c == '&')
- out.append("&");
- else if (c == ' ')
- out.append(" ");
- else if (c == 'n')
- out.append("<br/>");
- else
- out.append(c);
- }
- return out.toString();
- }
- %>
- <%!
- public static String toValidString(String in){
- StringBuffer out = new StringBuffer();
- for (int i = 0; in != null && i < in.length(); i++) {
- char c = in.charAt(i);
- if (c == ''')
- out.append("'");
- //else if (c == '"')
- // out.append(""");
- else
- out.append(c);
- }
- return out.toString();
- }
- %>
- <%!
- public static String getGBString(String in){
- try{
- String _p=in;
- byte[] _t=_p.getBytes("ISO8859-1");
- String _out=new String(_t);
- return _out;
- }
- catch(Exception e){
- }
- return "null";
- }
- %>
- <script language="javascript">
- //AdjustImg('pimg','200','150')
- //*************************************************
- function AdjustImg(img_obj,w,h){
- w=500;
- window.setTimeout("i=1",10000);
- oWidth=img_obj.width;
- oHeight=img_obj.height;
- oRate=oWidth/oHeight;
- if (w!=0 && w!=0) {
- nRate=w/h
- if (nRate>oRate) {
- if (w<oWidth) {
- img_obj.width=w;
- img_obj.height=w/oRate;
- }
- } else {
- if (h<oHeight){
- img_obj.height=h;
- img_obj.width=h*oRate;
- }
- }
- } else if (w==0) {
- if (h<oHeight) {
- img_obj.height=h;
- img_obj.width=h*oRate;
- }
- } else if (h==0) {
- if (w<oWidth) {
- img_obj.width=w;
- img_obj.height=w/oRate;
- }
- }
- }
- </script>