当前位置: 代码迷 >> JavaScript >> js-惯用的js
  详细解决方案

js-惯用的js

热度:26   发布时间:2012-12-21 12:03:49.0
js---常用的js

1、子窗口更新父窗口的控件的值

父窗口代码:

<input type="text" id="fileName" name="imageName">
在子窗口中可以根据id找到并且赋值给value:
window.opener.document.getElementById("fileName").value = "newValue"

2、js动态设置img 的src属性:

实现预览效果

html代码:

<img src="" id="showImage" width="100" alt="">


js代码:
var image = window.opener.document.getElementById("showImage")
				image.src = 'updata/'+filePathName

3、js实现返回上一页面:

history.go(-1)

或者:

history.back(-1)

4、js实现页面的重定向:

window.location.href='login.asp'


  相关解决方案