不过是加了几个按钮 然后改了一下快捷键而已 而且现在焦点可以移动过去 可是怎么按回车就不管用了呢 烦死了烦死了 还有就是关于隐藏父窗体的事情 搞不定了
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /><script type="text/javascript">var oPopup = window.createPopup();var buttonMonitor = {};
var highlightButton = null;
var topButtons = null;function SetHighlightButton(btn) {
BlackoutHighlightButton();
highlightButton = btn;
btn.style.backgroundColor = "yellow";
}
function BlackoutHighlightButton() {
if (highlightButton)
highlightButton.style.backgroundColor = "";
}
function HighlightPreviousButton() {
if (highlightButton
&& highlightButton.PreviousButton)
SetHighlightButton(highlightButton.PreviousButton);
}
function HighlightNextButton() {
if (highlightButton
&& highlightButton.NextButton)
SetHighlightButton(highlightButton.NextButton);
}
function HighlightFirstUpButton() {
if (highlightButton
&& highlightButton.FirstUpButton)
SetHighlightButton(highlightButton.FirstUpButton);
}
function HighlightFirstDownButton() {
if (highlightButton
&& highlightButton.FirstDownButton)
SetHighlightButton(highlightButton.FirstDownButton);
}function SetButtonMonitor(keyName) {
buttonMonitor[keyName] = true;
}
function GetButtonMonitor(keyName) {
return buttonMonitor[keyName];
}
function ResetButtonMonitor() {
for (var p in buttonMonitor)
{
buttonMonitor[p] = false;
}
}function InitializePopup() {
var pBody = oPopup.document.body;
pBody.style.border = "solid black 1px";
pBody.innerHTML = ""; var dy = oPopup.document.createElement("button");
dy.innerHTML = "电影(1)";
pBody.appendChild(dy); var dsj = oPopup.document.createElement("button");
dsj.innerHTML = "电视剧(2)";
pBody.appendChild(dsj); var zx = oPopup.document.createElement("button");
zx.innerHTML = "资讯(3)";
pBody.appendChild(zx);
var dm = oPopup.document.createElement("button");
dm.innerHTML = "动漫(4)";
pBody.appendChild(dm);
var yl = oPopup.document.createElement("button");
yl.innerHTML = "娱乐(5)";
pBody.appendChild(yl);
var leftDiv = oPopup.document.createElement("div");
leftDiv.id = "leftDiv";
leftDiv.style.styleFloat = "left";
leftDiv.style.border = "1px dashed red";
leftDiv.style.width = "399px";
leftDiv.style.height = "500px";
pBody.appendChild(leftDiv); var rightDiv = oPopup.document.createElement("div");
rightDiv.id = "rightDiv";
rightDiv.style.styleFloat = "right";
rightDiv.style.border = "1px solid blue";
rightDiv.style.width = "399px";
rightDiv.style.height = "500px";
pBody.appendChild(rightDiv); dy.onclick = function() {
dy();
}; dsj.onclick = function() {
dsj();
};
zx.onclick = function() {
zx();
};
dm.onclick = function() {
dm();
};
yl.onclick = function() {
yl();
};
SetHighlightButton(dy);
dy.NextButton = dsj;
dsj.PreviousButton = dy;
dsj.NextButton = zx;
zx.PreviousButton = dsj;
zx.NextButton = dm;
dm.PreviousButton = zx;
dm.NextButton = yl;
yl.PreviousButton = dm; topButtons = [dy, dsj, zx, dm, yl];
//alert(topButtons.length);
}function ShowPopup()
{
oPopup.show(100,0,800,600,document.body)
}function key_short(){
if (event == null)
{
alert("event is null: true.");
}
else
{
//alert(window.event.keyCode);
var key = window.event.keyCode;
if(key==49) dy();
if(key==50) dsj();
if(key==51) zx();
if(key==52) dm();
if(key==53) yl();
if(key==67) c();
if(key==68) d();
if(key==69) e();
if(key==70) f(); // Left arrow
if(key==37) HighlightPreviousButton();
// Right arrow
if(key==39) HighlightNextButton();
// Up arrow
if(key==38) HighlightFirstUpButton();
// Down arrow
if(key==40) HighlightFirstDownButton();
// Enter
if (key==13 && highlightButton)
highlightButton.click();
}
}function dy(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = ""; var btnc = oPopup.document.createElement("button");
btnc.innerHTML = "恐怖片(c)";
btnc.onclick = c;
leftDiv.appendChild(btnc); var btnd = oPopup.document.createElement("button");
btnd.innerHTML = "爱情片(d)";
btnd.onclick = d;
leftDiv.appendChild(btnd); ResetButtonMonitor();
SetButtonMonitor("c");
SetButtonMonitor("d"); SetHighlightButton(btnc);
btnc.NextButton = btnd;
btnd.PreviousButton = btnc; btnc.FirstUpButton = topButtons[0];
btnd.FirstUpButton = topButtons[0]; topButtons[0].FirstDownButton = btnc;
topButtons[1].FirstDownButton = btnc;
}
function dsj(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = ""; var btne = oPopup.document.createElement("button");
btne.innerHTML = "内地电视剧(e)";
btne.onclick = e;
leftDiv.appendChild(btne); var btnf = oPopup.document.createElement("button");
btnf.innerHTML = "港台电视剧(f)";
btnf.onclick = f;
leftDiv.appendChild(btnf); ResetButtonMonitor();
SetButtonMonitor("e");
SetButtonMonitor("f"); SetHighlightButton(btne);
btne.NextButton = btnf;
btnf.PreviousButton = btne; btne.FirstUpButton = topButtons[0];
btnf.FirstUpButton = topButtons[0]; topButtons[0].FirstDownButton = btne;
topButtons[1].FirstDownButton = btne;
}
function zx(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = ""; // var btnc = oPopup.document.createElement("button");
// btnc.innerHTML = "恐怖片(c)";
// btnc.onclick = c;
// leftDiv.appendChild(btnc); // var btnd = oPopup.document.createElement("button");
// btnd.innerHTML = "爱情片(d)";
//btnd.onclick = d;
//leftDiv.appendChild(btnd); // ResetButtonMonitor();
// SetButtonMonitor("c");
// SetButtonMonitor("d"); //SetHighlightButton(btnc);
// btnc.NextButton = btnd;
// btnd.PreviousButton = btnc; // btnc.FirstUpButton = topButtons[0];
// btnd.FirstUpButton = topButtons[0]; // topButtons[0].FirstDownButton = btnc;
// topButtons[1].FirstDownButton = btnc;
}function dm(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = ""; var ds = oPopup.document.createElement("button");
ds.innerHTML = "电视(c)";
ds.onclick = c;
leftDiv.appendChild(ds); var jc = oPopup.document.createElement("button");
jc.innerHTML = "剧场(d)";
jc.onclick = d;
leftDiv.appendChild(jc); ResetButtonMonitor();
SetButtonMonitor("c");
SetButtonMonitor("d"); SetHighlightButton(ds);
ds.NextButton = jc;
jc.PreviousButton = ds; ds.FirstUpButton = topButtons[0];
jc.FirstUpButton = topButtons[0]; topButtons[0].FirstDownButton = ds;
topButtons[1].FirstDownButton = ds;
}
function yl(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = "";
}function c(){
if (GetButtonMonitor("c"))
oPopup.document.getElementById("rightDiv").innerHTML = "播放恐怖片 :(";
}
function d(){
if (GetButtonMonitor("d"))
oPopup.document.getElementById("rightDiv").innerHTML = "播放爱情片 :b...";
}
function e(){
if (GetButtonMonitor("e"))
oPopup.document.getElementById("rightDiv").innerHTML = "播放内地电视剧 ^_^";
}
function f(){
if (GetButtonMonitor("f"))
oPopup.document.getElementById("rightDiv").innerHTML = "播放港台电视剧 @_@";
}InitializePopup();</script>
</head><body>
<button onclick="ShowPopup()">Create pop-up!</button>
</body>
<script type="text/javascript">
<!--
document.body.onkeydown = function() {
if (oPopup.isOpen)
{
// Debug:
// 打开 alert 时,ShowPopup 须同时打开! //alert(event.keyCode);
key_short();
//ShowPopup();
}
};
//-->
</script>
</html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /><script type="text/javascript">var oPopup = window.createPopup();var buttonMonitor = {};
var highlightButton = null;
var topButtons = null;function SetHighlightButton(btn) {
BlackoutHighlightButton();
highlightButton = btn;
btn.style.backgroundColor = "yellow";
}
function BlackoutHighlightButton() {
if (highlightButton)
highlightButton.style.backgroundColor = "";
}
function HighlightPreviousButton() {
if (highlightButton
&& highlightButton.PreviousButton)
SetHighlightButton(highlightButton.PreviousButton);
}
function HighlightNextButton() {
if (highlightButton
&& highlightButton.NextButton)
SetHighlightButton(highlightButton.NextButton);
}
function HighlightFirstUpButton() {
if (highlightButton
&& highlightButton.FirstUpButton)
SetHighlightButton(highlightButton.FirstUpButton);
}
function HighlightFirstDownButton() {
if (highlightButton
&& highlightButton.FirstDownButton)
SetHighlightButton(highlightButton.FirstDownButton);
}function SetButtonMonitor(keyName) {
buttonMonitor[keyName] = true;
}
function GetButtonMonitor(keyName) {
return buttonMonitor[keyName];
}
function ResetButtonMonitor() {
for (var p in buttonMonitor)
{
buttonMonitor[p] = false;
}
}function InitializePopup() {
var pBody = oPopup.document.body;
pBody.style.border = "solid black 1px";
pBody.innerHTML = ""; var dy = oPopup.document.createElement("button");
dy.innerHTML = "电影(1)";
pBody.appendChild(dy); var dsj = oPopup.document.createElement("button");
dsj.innerHTML = "电视剧(2)";
pBody.appendChild(dsj); var zx = oPopup.document.createElement("button");
zx.innerHTML = "资讯(3)";
pBody.appendChild(zx);
var dm = oPopup.document.createElement("button");
dm.innerHTML = "动漫(4)";
pBody.appendChild(dm);
var yl = oPopup.document.createElement("button");
yl.innerHTML = "娱乐(5)";
pBody.appendChild(yl);
var leftDiv = oPopup.document.createElement("div");
leftDiv.id = "leftDiv";
leftDiv.style.styleFloat = "left";
leftDiv.style.border = "1px dashed red";
leftDiv.style.width = "399px";
leftDiv.style.height = "500px";
pBody.appendChild(leftDiv); var rightDiv = oPopup.document.createElement("div");
rightDiv.id = "rightDiv";
rightDiv.style.styleFloat = "right";
rightDiv.style.border = "1px solid blue";
rightDiv.style.width = "399px";
rightDiv.style.height = "500px";
pBody.appendChild(rightDiv); dy.onclick = function() {
dy();
}; dsj.onclick = function() {
dsj();
};
zx.onclick = function() {
zx();
};
dm.onclick = function() {
dm();
};
yl.onclick = function() {
yl();
};
SetHighlightButton(dy);
dy.NextButton = dsj;
dsj.PreviousButton = dy;
dsj.NextButton = zx;
zx.PreviousButton = dsj;
zx.NextButton = dm;
dm.PreviousButton = zx;
dm.NextButton = yl;
yl.PreviousButton = dm; topButtons = [dy, dsj, zx, dm, yl];
//alert(topButtons.length);
}function ShowPopup()
{
oPopup.show(100,0,800,600,document.body)
}function key_short(){
if (event == null)
{
alert("event is null: true.");
}
else
{
//alert(window.event.keyCode);
var key = window.event.keyCode;
if(key==49) dy();
if(key==50) dsj();
if(key==51) zx();
if(key==52) dm();
if(key==53) yl();
if(key==67) c();
if(key==68) d();
if(key==69) e();
if(key==70) f(); // Left arrow
if(key==37) HighlightPreviousButton();
// Right arrow
if(key==39) HighlightNextButton();
// Up arrow
if(key==38) HighlightFirstUpButton();
// Down arrow
if(key==40) HighlightFirstDownButton();
// Enter
if (key==13 && highlightButton)
highlightButton.click();
}
}function dy(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = ""; var btnc = oPopup.document.createElement("button");
btnc.innerHTML = "恐怖片(c)";
btnc.onclick = c;
leftDiv.appendChild(btnc); var btnd = oPopup.document.createElement("button");
btnd.innerHTML = "爱情片(d)";
btnd.onclick = d;
leftDiv.appendChild(btnd); ResetButtonMonitor();
SetButtonMonitor("c");
SetButtonMonitor("d"); SetHighlightButton(btnc);
btnc.NextButton = btnd;
btnd.PreviousButton = btnc; btnc.FirstUpButton = topButtons[0];
btnd.FirstUpButton = topButtons[0]; topButtons[0].FirstDownButton = btnc;
topButtons[1].FirstDownButton = btnc;
}
function dsj(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = ""; var btne = oPopup.document.createElement("button");
btne.innerHTML = "内地电视剧(e)";
btne.onclick = e;
leftDiv.appendChild(btne); var btnf = oPopup.document.createElement("button");
btnf.innerHTML = "港台电视剧(f)";
btnf.onclick = f;
leftDiv.appendChild(btnf); ResetButtonMonitor();
SetButtonMonitor("e");
SetButtonMonitor("f"); SetHighlightButton(btne);
btne.NextButton = btnf;
btnf.PreviousButton = btne; btne.FirstUpButton = topButtons[0];
btnf.FirstUpButton = topButtons[0]; topButtons[0].FirstDownButton = btne;
topButtons[1].FirstDownButton = btne;
}
function zx(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = ""; // var btnc = oPopup.document.createElement("button");
// btnc.innerHTML = "恐怖片(c)";
// btnc.onclick = c;
// leftDiv.appendChild(btnc); // var btnd = oPopup.document.createElement("button");
// btnd.innerHTML = "爱情片(d)";
//btnd.onclick = d;
//leftDiv.appendChild(btnd); // ResetButtonMonitor();
// SetButtonMonitor("c");
// SetButtonMonitor("d"); //SetHighlightButton(btnc);
// btnc.NextButton = btnd;
// btnd.PreviousButton = btnc; // btnc.FirstUpButton = topButtons[0];
// btnd.FirstUpButton = topButtons[0]; // topButtons[0].FirstDownButton = btnc;
// topButtons[1].FirstDownButton = btnc;
}function dm(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = ""; var ds = oPopup.document.createElement("button");
ds.innerHTML = "电视(c)";
ds.onclick = c;
leftDiv.appendChild(ds); var jc = oPopup.document.createElement("button");
jc.innerHTML = "剧场(d)";
jc.onclick = d;
leftDiv.appendChild(jc); ResetButtonMonitor();
SetButtonMonitor("c");
SetButtonMonitor("d"); SetHighlightButton(ds);
ds.NextButton = jc;
jc.PreviousButton = ds; ds.FirstUpButton = topButtons[0];
jc.FirstUpButton = topButtons[0]; topButtons[0].FirstDownButton = ds;
topButtons[1].FirstDownButton = ds;
}
function yl(){
var leftDiv = oPopup.document.getElementById("leftDiv");
leftDiv.innerHTML = "";
}function c(){
if (GetButtonMonitor("c"))
oPopup.document.getElementById("rightDiv").innerHTML = "播放恐怖片 :(";
}
function d(){
if (GetButtonMonitor("d"))
oPopup.document.getElementById("rightDiv").innerHTML = "播放爱情片 :b...";
}
function e(){
if (GetButtonMonitor("e"))
oPopup.document.getElementById("rightDiv").innerHTML = "播放内地电视剧 ^_^";
}
function f(){
if (GetButtonMonitor("f"))
oPopup.document.getElementById("rightDiv").innerHTML = "播放港台电视剧 @_@";
}InitializePopup();</script>
</head><body>
<button onclick="ShowPopup()">Create pop-up!</button>
</body>
<script type="text/javascript">
<!--
document.body.onkeydown = function() {
if (oPopup.isOpen)
{
// Debug:
// 打开 alert 时,ShowPopup 须同时打开! //alert(event.keyCode);
key_short();
//ShowPopup();
}
};
//-->
</script>
</html>
另外,好像FF不支持window.createPopup();?