js 知识点

来源:互联网 发布:js正则表达式\< 编辑:程序博客网 时间:2024/05/31 19:55

1.关闭父窗口,且屏蔽 是否关闭 的提示框,参考http://www.w3school.com.cn/htmldom/dom_obj_window.asp
 parent.window.open("",'_self',"");parent.window.close();

2.刷新父窗口:parent.window.opener.document.execCommand("refresh");

2.java里构造json数据时,要这样pw.print("{\"error\":\""+String.valueOf(map.get("error"))+"\"}");今天整惨了,为了这个格式即{"key":"value"}
输出设置防止乱码response.setContentType("text/json;charset=utf-8");

3.$('#select button')[0].style.textIndent=23+'px';jquery取得id=select标签内的button标签,再缩进button上的文字,实现隐藏;
js操作css直接obj.style.样式,如果有下划线直接去掉(如:text_indent换成textIndent)

4.自适应高度iframe,jquery代码,这个代码写在iframe所引用的页面里,contentFrame是父页面的iframe的id
$(function(){
        var parentIframe = $(window.parent.document).find("#contentFrame");
        var childHeight = $(document).height();
        parentIframe.height(childHeight);        
    });