Simple implementation code of js pop up window
- 2021-08-05 08:36:12
- OfStack
In this paper, we share the specific code displayed in the js pop-up window for your reference. The specific contents are as follows
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
body{
/*margin: 0;*/
}
#div1{
width: 100px;
height: 100px;
border: 1px solid red;
}
</style>
</head>
<body>
<div id="div1" onmouseover="getInfo(this)" onmouseout="this.innerHTML=''">
</div>
<button onclick="getInfo()"> Get div Information </button>
<hr/>
<a href="111.html" rel="external nofollow" target="_blank"> I am a hyperlink </a>
<br/><br/>
<button onclick="myopen1()"> New window 111111111</button>
<button onclick="myopen2()"> New window 222222222</button>
<button onclick="myopen3()"> New window 333333333</button>
<hr/>
<button onclick="myclose()"> Close the child window </button>
<script>
var mywin;
function myclose(){
if(mywin)
mywin.close();
}
function myopen3(){
mywin = window.open('333.html', 'news', 'resizable=no');
}
function myopen2(){
mywin = window.open('222.html', 'news', 'resizable=no');
}
function myopen1(){
mywin = window.open('111.html', 'news', 'resizable=no');
}
function getInfo(obj){
// var div1 = document.getElementById('div1');
obj.innerHTML = obj.offsetWidth+',,'+obj.offsetHeight;
obj.innerHTML += '<br>'+obj.offsetLeft+',,'+obj.offsetTop;
// offsetXXX It can only be read and cannot be modified by assignment
obj.offsetWidth = obj.offsetWidth+100;
// The following properties are no longer available
// obj.innerHTML += '<br>'+obj.innerWidth+',,'+obj.innerHeight;
}
</script>
</body>
</html>