这是我的代码:
<button onclick="myFunction()">Fullscreen</button>
<script>
function myFunction() {
var myWindow = window.open("", "myWindow", "width=500,height=400");
myWindow.document.write("<script
src=‘ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js’><\/script>
<script src=‘ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js’>
<\/script><script type=‘text/javascript’>var
resizeOwnEmulator=function(width,height){var emulator=$('#emulator');emulator.css('width',width);emulator.css('height',height)}$(function(){function embed(){var emulator=$('#emulator');if(emulator){var flashvars={system:'gb',url:'/uploads/2/6/7/6/26766876/pokemon-gold.zip'};var params={};var attributes={};params.allowscriptaccess='sameDomain';params.allowFullScreen='true';params.allowFullScreenInteractive='true';swfobject.embedSWF('/uploads/3/8/8/3/38833005/nesbox.swf','emulator','640','480','11.2.0','/flash/bin/expressInstall.swf',flashvars,params,attributes)}}embed()});<\/script>");
myWindow.document.close();
var p = document.createElement("p")
p.innerHTML = "This is the source window!";
opener.document.querySelector("body").appendChild(p)
}
</script>
我正在尝试获取弹出窗口以显示Flash文件,但它只是在开发控制台中返回此消息:
swfobject.js%E2%80%99:1 Failed to load resource: the server responded with a
status of 404 (Not Found)
jquery.min.js%E2%80%99:1 Failed to load resource: the server responded with
a status of 404 (Not Found)
它可能与
<script src=‘ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js’>
为此,我可能需要双引号,但是我不能在document.write(“”)中加上双引号。
最佳答案
我可能需要双引号
您可以使用:
U + 0022:引号
U + 0027:撇号{APL quote}
您不能但正在尝试使用:
U + 2018:左单引号{单引号逗号}
U + 2019:正确的单引号{单逗号引号}
这通常是由于尝试使用文字处理器而不是文本编辑器编写代码引起的。
但我不能在document.write(“”)中加上双引号
您可以。可以在JS的字符串文字中将"
字符转义为\"
。
关于javascript - 无法在document.write中获取脚本源,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53228752/