js---常用的js

来源:互联网 发布:看课外书的软件 编辑:程序博客网 时间:2024/05/22 10:29

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'


原创粉丝点击