-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
105 lines (90 loc) · 2.79 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!Doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="请关注ManYouIT,如果你想给自己多加特技的话。">
<title>同时在多个网站查字典——ManYouIT</title>
<style type="text/css">
* {
box-sizing: border-box;
}
body{
margin: 0;
padding: 0;
}
iframe{
display: inline;
padding: 0px;
margin: 0;
border-collapse: collapse;
border-right-width: 1px;
border-color: lightblue;
width: 33.33333333%;
height: 1250px;
}
#the_word{
margin: 0 auto;
display: block;
width: 100%;
height: 30px;
border-width: 0px;
border-color: red;
text-align: center;
font-size: 26px;
}
#header{
text-align: center;
}
</style>
</head>
<body>
<div id="header">
<input id="the_word" placeholder="点此输入单词,然后按下Enter或者移开鼠标指针" onkeypress="if(event.keyCode==13)lookUp()" onmouseout="lookUp()" onclick="this.select()" type="text"/>
</div>
<section><iframe id="cnki"></iframe><iframe id="Merriam"></iframe><iframe id="youdao"></iframe></section>
<script type="text/javascript" >
function display_larger(){
var f = document.querySelectorAll("iframe");
for (var i = 0; i < f.length; i++) {
if(f[i]!=this)f[i].style.width="5%";
};
this.style.width= "90%" ;
}
var f = document.querySelectorAll("iframe");
for (var i = 0; i < f.length; i++) {
f[i].addEventListener("mouseover", display_larger);
};
function revert(){
var f = document.querySelectorAll("iframe");
for (var i = 0; i < f.length; i++) {
if(f[i]!=this)f[i].style.width="33.33333333%";
};
}
document.querySelector("section").addEventListener("mouseout", revert);
// function click_or_blur(e){
// if (document.selection) {
// var range = document.body.createTextRange();
// range.moveToElementText(this);
// range.select();
// } else if (window.getSelection) {
// var range = document.createRange();
// range.selectNodeContents(this);
// window.getSelection().addRange(range);
// }
// }
// document.getElementById("the_word").addEventListener("click",click_or_blur);
function lookUp(){
//定义了输入值,并且把值转换成URI
var word=document.getElementById("the_word");
if(word.value!=word.getAttribute("placeholder") && word.value.replace(/ * */g,"")!=""){
var input_value = word.value;
input_value = encodeURI(input_value);
document.getElementsByTagName("iframe")[1].setAttribute('src','//dict.youdao.com/search?le=eng&q='+ input_value+ '&keyfrom=dict.top');
document.getElementsByTagName("iframe")[2].setAttribute('src','//dict.baidu.com/s?wd='+ input_value);
document.getElementsByTagName("iframe")[0].setAttribute('src','//www.bing.com/dict/search?q='+ input_value);
word.setAttribute("placeholder", word.value);
}
}
</script>
</body>
</html>