Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Javascript汇总Iframe中的所有按键_Javascript_Html_Google Apps Script_Iframe - Fatal编程技术网

使用Javascript汇总Iframe中的所有按键

使用Javascript汇总Iframe中的所有按键,javascript,html,google-apps-script,iframe,Javascript,Html,Google Apps Script,Iframe,我使用AppScript创建了一个简单的网站。在我的页面中,我有一个禁用的框和3列嵌入了我的工作工具的iframe。(出于隐私目的,我已更改URL) 这是我的网站: 我需要的是,一旦我点击任何iframe并打开我的工作工具并按下其中一个字母(A、S、D、‘Shift+Enter’、U、Y、T&N),它将计算我在iframe中按下该字母的次数,并在我网站上方的禁用框中显示该值。我有3个iframe,无论何时我选择都会有相同的结果 这是我的密码: <!DOCTYPE html> <

我使用AppScript创建了一个简单的网站。在我的页面中,我有一个禁用的框和3列嵌入了我的工作工具的iframe。(出于隐私目的,我已更改URL)

这是我的网站:

我需要的是,一旦我点击任何iframe并打开我的工作工具并按下其中一个字母(A、S、D、‘Shift+Enter’、U、Y、T&N),它将计算我在iframe中按下该字母的次数,并在我网站上方的禁用框中显示该值。我有3个iframe,无论何时我选择都会有相同的结果

这是我的密码:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">

<style>
body {
 margin: 0;
}

.row {
 display: flex;
 flex-wrap: wrap;
}

.embed-responsive {
 position: relative;
 display: block;
 width: 100%;
 padding: 0;
 overflow: hidden;
}

.embed-responsive::before {
 display: block;
 content: "";
}

.embed-responsive .embed-responsive-item {
 left: 0;
 width: 100%;
}

.col-md-4 {
 width: 100%;
 padding: 15px;
 box-sizing: border-box;
}

@media(min-width: 768px) {
 .col-md-4 {
  max-width: 33.33333%;
  flex: 0 0 33.33333%;
 }
}
</style>

</head>
    <body onload="window.resizeTo(600,800)">
    <input type="text" placeholder="total ticket" style="margin-left:19px;" disabled >
        <div class="row">
          <div class="col-md-4">
            <div class="embed-responsive embed-responsive-16by9">
              <iframe class="embed-responsive-item" src="URL HERE" width="98%" height="1000px" ></iframe>
            </div>
          </div>
          <div class="col-md-4">
            <div class="embed-responsive embed-responsive-16by9">
              <iframe class="embed-responsive-item" src="URL HERE" width="98%" height="1000px"></iframe>
            </div>
          </div>
          <div class="col-md-4">
            <div class="embed-responsive embed-responsive-16by9">
              <iframe class="embed-responsive-item" src="URL HERE" width="98%" height="1000px"></iframe>
           </div>
         </div>
       </div>
    </body>
</html>
<script>
function isCharacterKeyPress(evt) {
    if (typeof evt.which == "undefined") {
        // This is IE, which only fires keypress events for printable keys
        return true;
    } else if (typeof evt.which == "number" && evt.which > 0) {
        // In other browsers except old versions of WebKit, evt.which is
        // only greater than zero if the keypress is a printable key.
        // We need to filter out backspace and ctrl/alt/meta key combinations
        return !evt.ctrlKey && !evt.metaKey && !evt.altKey && evt.which != 8;
    }
    return false;
}

<input type="text" onkeypress="alert(isCharacterKeyPress(event))">
</script>

身体{
保证金:0;
}
.行{
显示器:flex;
柔性包装:包装;
}
.嵌入响应{
位置:相对位置;
显示:块;
宽度:100%;
填充:0;
溢出:隐藏;
}
.embed responsive::before{
显示:块;
内容:“;
}
.嵌入响应。嵌入响应项{
左:0;
宽度:100%;
}
.col-md-4{
宽度:100%;
填充:15px;
框大小:边框框;
}
@介质(最小宽度:768px){
.col-md-4{
最大宽度:33.33333%;
弹性:0.33.33333%;
}
}
功能isCharacterKeyPress(evt){
if(evt.WHIT的类型==“未定义”){
//这是IE,它只为可打印的按键触发按键事件
返回true;
}else if(evt.which==“number”&&evt.which>0的类型){
//在除旧版本WebKit外的其他浏览器中,evt
//仅当按键为可打印按键时才大于零。
//我们需要过滤掉backspace和ctrl/alt/meta键组合
return!evt.ctrlKey&&!evt.metaKey&!evt.altKey&&evt.which!=8;
}
返回false;
}

我的JavaScript不工作。有人能帮我吗?“有别的方法吗?”-你的方法行得通吗?如果不是这样,那么另一种选择是可行的。如果它真的起作用,那有什么问题吗?那么。。。“此处URL”是同一域还是跨(其他)域。。。如果是跨域的,那么就放弃,除非你还控制“URL HERE”的代码,它是另一个域。客户提供的工作工具。我试着将它嵌入到我的html中,希望我能监控我正在处理的所有票据。有没有办法做到这一点?javascript无法在不同域的iframe中访问太多内容。。。有很多方法。。但是iframe中的代码必须配合
window.postMessage
是您需要的,window.postMessage做什么?对不起,我问得太多了。“有没有别的办法?”-你的办法行吗?如果不是这样,那么另一种选择是可行的。如果它真的起作用,那有什么问题吗?那么。。。“此处URL”是同一域还是跨(其他)域。。。如果是跨域的,那么就放弃,除非你还控制“URL HERE”的代码,它是另一个域。客户提供的工作工具。我试着将它嵌入到我的html中,希望我能监控我正在处理的所有票据。有没有办法做到这一点?javascript无法在不同域的iframe中访问太多内容。。。有很多方法。。但是iframe中的代码必须配合
window.postMessage
是您需要的,window.postMessage做什么?对不起,我要求太多了。