1)获取id
document.getElementById('iframeDiv')
2)获取class
document.getElementsByClassName('iframeDiv')
var iframeDiv = document.getElementsByClassName('iframeDiv')
for (let i = 0; i < iframeDiv.length; i++) {
console.log(iframeDiv[i])
}
3)设置style
dom.setAttribute('style', 'width:50%;height:50%')
4)页面跳转
window.location.href = "http://localhost:9528/#/login?server=" + host
5)获取连接?后的参数
http://localhost:9528/#/login?server=www.jy-sh.com
console.log(getParams('server')) // www.jy-sh.com
function getParams(name) {
var search = window.location.search.substring(1)
if (!search) {
search = window.location.hash.split('?')[1]
}
if (search) {
var obj = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}')
return name ? obj[name] : obj
}
}
6)settimeout
setTimeout(() => {
document.getElementById('iframe').setAttribute('style', 'width:400px;height:600px')
}, 10000);