Skip to content

{ Tag Archives } javascript

用jquery解析xml

首先,如果是动态生成的xml,必须设置Content-Type为”text/xml”,否则默认的就是文本了。 其次,生成的xml必须为封闭的。即格式一定要正确。 这样,就可以解析了xml,例: ?View Code JAVASCRIPT$.ajax({ url:’ajax.asp’, type: ‘GET’, dataType: ‘xml’,//这里可以不写,但千万别写text或者html!!! timeout: 1000, error: function(xml){ alert(’Error loading XML document’+xml); }, success: function(xml){ $(xml).find("student").each(function(i){ var id=$(this).children("id"); //取对象 var id_value=$(this).children("id").text(); //取文本 alert(id_value);//这里就是ID的值了。 alert($(this).attr("email")); //这里能显示student下的email属性。 $(’<li></li>’) .html(id_value) .appendTo(’ol’); }); } });

Also tagged ,

javascript中目录的表示方式

在网上路径上有两种表示方式,一种是绝对路径(Absolute Path),另一种是相对路径(Relative Path)。 绝对路径是包括了整个访问地址,如:http://www.080909.com/wordpress/index.php。 所谓相对路径,顾名思义就是自己相对与目标位置。其中,”./”表示为当前目录,等同于不写。”../”上级目录,”/”根目录。 例如,当前访问的网站是http://www.080909.com/wordpress/index.php这个页面中。<script src=”../test.js” type=”text/javascript”></script> 实际上按绝对位置来说就是 http://www.080909.com/test.js.而如果是这样<script src=”./test.js” type=”text/javascript”></script>,则绝对位置就是 http://www.080909.com/wordpress/test.js。而如果是这样<script src=”/test.js” type=”text/javascript”></script>那么http://www.080909.com/test.js就是这种表示方式的绝对路径。

Also tagged

用div模拟窗体

不知为什么在firefox下显示不正常,而在IE下可以显示。 <div id="pop" style="border:1px solid #CCC; background-color:White;padding:3px;width:200px "> <div style="background-color:#336699;cursor:default; width:100%;float: left;"> <div style="padding-left:3px;color:White; float:left; border-width:0px;">查询</div> <div class="pdtRight" style="width:12px;border-width:0px; color:White;font-family:webdings; float: right;cursor:pointer;">r</div> </div> <div> 测试 </div> </div> 提示:你可以先修改部分代码再运行。

Also tagged ,

如何让页面关闭时,不弹出提示框

增加一个javascript函数: ?View Code JAVASCRIPTfunction closewindow(){ window.opener = null; window.open(”, ‘_self’, ”); window.close(); } 在关闭时调用该函数。 ?View Code HTML4STRICT<input type="button" value="关闭" onclick="closewindow()" />

Also tagged