Javascript 如何在弹出窗口中编辑html?
所以,我知道如何在google中创建一个弹出窗口,我知道如何在弹出窗口中写入内容,但是我如何在弹出窗口中添加其他HTML标记呢 下面是我的Html代码Javascript 如何在弹出窗口中编辑html?,javascript,html,popup,Javascript,Html,Popup,所以,我知道如何在google中创建一个弹出窗口,我知道如何在弹出窗口中写入内容,但是我如何在弹出窗口中添加其他HTML标记呢 下面是我的Html代码 <html> <head> <script> function openWin() { myWindow=window.open("","","width=200,height=100"); myWindow.document.write("<p>NEW WINDOW<p>"); } &
<html>
<head>
<script>
function openWin()
{
myWindow=window.open("","","width=200,height=100");
myWindow.document.write("<p>NEW WINDOW<p>");
}
</script>
</head>
<body>
<button onmousedown='openWin();'>Hello</button>
</body>
</html>
函数openWin()
{
myWindow=window.open(“,”,“宽度=200,高度=100”);
myWindow.document.write(“新窗口”);
}
你好
如您所见,在document.write函数中,我有两个
标记,我也可以使用标记,但我不能使用标记,有人知道原因吗,或者是否可能吗?所以您正在尝试将标记写入弹出窗口?你必须这样做:
<html>
<head>
<script>
function openWin()
{
myWindow=window.open("","","width=200,height=100");
myWindow.document.open();
myWindow.document.write("<p>NEW WINDOW<p>");
myWindow.document.write("<scr" + "ipt>alert('Script works!')</scr"+"ipt>");
myWindow.document.close();
}
</script>
</head>
<body>
<button onmousedown='openWin();'>Hello</button>
</body>
</html>
函数openWin()
{
myWindow=window.open(“,”,“宽度=200,高度=100”);
myWindow.document.open();
myWindow.document.write(“新窗口”);
myWindow.document.write(“警报('Script works!'));
myWindow.document.close();
}
你好
否则,父窗口将认为脚本标记是它应该解释的内容。您不能将“”或“”写入窗口,这是特别不允许的。你必须把这些条款分开
function openWin() {
myWindow=window.open("","","width=200,height=100");
myWindow.document.write("<p>NEW WINDOW<p>");
myWindow.document.write("<scr");
myWindow.document.write("ipt>alert('Script works!')</scr")
myWindow.document.write("ipt>");
}
函数openWin(){
myWindow=window.open(“,”,“宽度=200,高度=100”);
myWindow.document.write(“新窗口”);
myWindow.document.write(“警报('Script works!'));
}
我觉得我们缺少的关键是,为什么要在弹出窗口中写入脚本标记?我很难想象一个场景中需要这样做…谢谢,我会尝试一下,然后告诉你我的想法。由于某种原因,当我尝试制作一个函数时,程序无法工作。出于测试目的,我正在尝试在弹出窗口上重新创建第一页。将我的答案复制为您自己的答案的方法。