2012-10-18 49 views
3

我一直在html编码的初学者,我想知道如果我可以直接写入窗口大小和其他属性到页面。 Il解释。从桌面打开文件到一个弹出窗口

我正在使用calc,我想在桌面上运行html文件。一切正常,但它会在打开其他选项卡的浏览器中启动。我希望它运行在一个没有状态栏的固定窗口大小的书签栏的小弹出窗口中。

编辑:

代码本身

<!doctype html> 
<html> 
<head><center>Kalkuraatur</center> 
<Title>Javascripti Kalkulaator</title> 
<script type="text/javascript"> 
    if(window.name != "mypopup") { 
     window.open(document.location.href,'mypopup', 'left=300,top=200,width=200,height=200,toolbar=0,status=0,location=0,menubar=0,scrollbars=0,titlebar=0'); var child = window.open(...; child.focus(); 
     window.close(); 
    } 
</script> 
<script type="text/javascript"> 
function arvuta() 
{ 
kalku.sisend.value = eval(kalku.sisend.value) 
} 
function Bspace(sisend) 
{ 
kalku.sisend.value = kalku.sisend.value.substring(0, kalku.sisend.value.length - 1) 
} 
</script> 
</head> 
<body> 
<center> 
<form name="kalku"> 
<table border=2> 
<tr><td> 
<input type="text" name="sisend" size="21"> 
<br> 
</td></tr> 
<tr><td> 
<input type="button" name="seitse" value=" 7 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '7'"> 
<input type="button" name="kaheksa" value=" 8 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '8'"> 
<input type="button" name="yheksa" value=" 9 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '9'"> 
<input type="button" name="ykstagasi" value="del" style="height: 22px; width: 30px" onclick="Bspace(this)"> 
<input type="button" name="kustuta" value=" C " style="height: 22px; width: 30px" onclick="kalku.sisend.value = ''"> 
<br> 
<input type="button" name="neli" value=" 4 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '4'"> 
<input type="button" name="viis" value=" 5 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '5'"> 
<input type="button" name="kuus" value=" 6 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '6'"> 
<input type="button" name="jaga" value=" ÷ " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '/'"> 
<input type="button" name="korruta" value=" x " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '*'"> 
<br> 
<input type="button" name="yks" value=" 1 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '1'"> 
<input type="button" name="kaks" value=" 2 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '2'"> 
<input type="button" name="kolm" value=" 3 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '3'"> 
<input type="button" name="lahuta" value=" - " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '-'"> 
<input type="button" name="plus" value=" + " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '+'"> 
<br> 
<input type="button" name="null" value=" 0 " style="height: 23px; width: 64px" onclick="kalku.sisend.value += '0'"> 
<input type="button" name="koma" value=" , " style="height: 22px; width: 30px" onclick="kalku.sisend.value += ','"> 
<input type="button" name="v6rdub" value=" = " style="height: 22px; width: 64px" onclick="arvuta()"> 
</td></tr> 
</form> 
</center> 
</body> 
</html> 
+0

你将不得不求助于JavaScript。尝试http://www.textfixer.com/html/javascript-pop-up-window.php,看看是否有帮助。 –

+0

calc是什么意思? –

+0

Calc为计算器,文件不会上传到任何位置。它在我的电脑里。 – Jakwobo

回答

1

如果你愿意来配置/对付弹出窗口拦截器,你可以添加这个作为第一个进入到你的HTML文档的头:

<script type="text/javascript"> 
    if(window.name != "mypopup") { 
     window.open(document.location.href,'mypopup', 'left=300,top=200,width=200,height=200,toolbar=0,status=0,location=0,menubar=0,scrollbars=0,titlebar=0'); 
     window.open('', '_self', ''); // chrome bug 
     window.close(); 
    } 
</script> 

没有测试过,但尝试一下本作的重点:

<script type="text/javascript"> 
    if(window.name != "mypopup") { 
     var childWindow = window.open(document.location.href,'mypopup', 'left=300,top=200,width=200,height=200,toolbar=0,status=0,location=0,menubar=0,scrollbars=0,titlebar=0'); 
     //like this 
     childWindow.focus(); 
     window.open('', '_self', ''); // chrome bug 
     window.close(); 
    } else { 
     //or like this 
     window.focus(); 
    } 
</script> 
+0

如何将其设置为打开顶部? – Jakwobo

+0

你可以在子窗口上调用** focus()**,尝试创建else并把它放在** window.focus()**中,或者你可以将window.open函数的返回值赋给var * * var child = window.open(...; child.focus(); ** – cbayram

+0

看到我的解决方案上我的意思编辑 – cbayram

0

据我知道浏览器窗口的大小是你不能使用HTML改变。现在您可以使用javascript和/或jQuery编写自己的弹出窗口。

添加一个“click to run calc”链接到用户将登陆的页面。当他们点击链接启动您的自定义弹出窗口。

这是我的意思是工作example

+0

我已经有了类似的东西,但我希望它立即在窗口中打开页面,而不必点击某个东西。 – Jakwobo

相关问题