[英]Button inside a popup window in Javascript
在Javascript中弹出窗口中有一个按钮需要什么代码? 然后该按钮的功能是转到另一个页面这是我的代码:
<script type="text/javascript">
function openWin() {
var myBtn = document.getElementById("myBtn");
myBtn = window.open('', '', 'width=200,height=300');
myBtn.document.write("<p>Lot Name: Esperanza</p>");
myBtn.document.write("<p>Lot Price: P800,000</p>");
myBtn.document.write("<p>Lot Size: 50 sq. metres</p>");
myBtn.focus();
function gotoreserve() {
window.location.href = "localhost/tola/reserve.php";
}
}
</script>
<script type="text/javascript">
function openWin() {
var myBtn = document.getElementById("myBtn");
myBtn = window.open('', '', 'width=200,height=300');
myBtn.document.write("<p>Lot Name: Esperanza</p>");
myBtn.document.write("<p>Lot Price: P800,000</p>");
myBtn.document.write("<p>Lot Size: 50 sq. metres</p>");
// Add a button element here
myBtn.document.write('<button onclick="gotoreserve()">Click Me!</button>');
myBtn.focus();
function gotoreserve() {
window.location.href = "localhost/tola/reserve.php";
}
}
</script>
<script type="text/javascript">
function openWin()
{
var myBtn=document.getElementById("myBtn");
myBtn=window.open('','','width=200,height=300');
myBtn.document.write("<p>Lot Name: Esperanza</p>");
myBtn.document.write("<p>Lot Price: P800,000</p>");
myBtn.document.write("<p>Lot Size: 50 sq. metres</p>");
myBtn.document.write("<input type='button' value='GoToReserve' onclick='gotoreserve()'>");
myBtn.focus();
function gotoreserve()
{
window.location.href = "localhost/tola/reserve.php";
}
}
</script>
尝试这种棘手的DOM方式,
<script type="text/javascript">
function openWin() {
var myBtn = document.getElementById("myBtn");
myBtn = window.open('', '', 'width=200,height=300');
myBtn.document.write("<p>Lot Name: Esperanza</p>");
myBtn.document.write("<p>Lot Price: P800,000</p>");
myBtn.document.write("<p>Lot Size: 50 sq. metres</p>");
// Add a button element here
var button = document.createElement("input");
button.type = "button";
button.value = "im a button";
button.onclick = "gotoreserve()";
mybtn.appendChild(button);
function gotoreserve() {
window.location.href = "localhost/tola/reserve.php";
}
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.