现在的位置: 首页 > 综合 > 正文

js—常用的js

2014年03月25日 ⁄ 综合 ⁄ 共 418字 ⁄ 字号 评论关闭

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'

抱歉!评论已关闭.