草庐IT

Postmessage

全部标签

javascript - react native html postMessage 无法到达 WebView

我使用ReactNativewebview来显示index.html,HTML将向应用程序发布消息。然后应用程序将接收消息并将其写入控制台。问题是当postMessage立即在头上运行时,应用程序无法接收消息。我认为这可能与HTML未完成加载有关。然后我使用setTimeout延迟,它起作用了。现在我想知道:有没有更好的方法来解决这个问题?为什么延迟100毫秒不起作用,而延迟200毫秒却起作用?我使用的是ReactNative版本0.39.0和Node版本7.2.0。这是我目前的代码:index.htmlIndex//cannotbereceivedpostMessage('sendt

javascript:监听来自特定 iframe 的 postMessage 事件

我在一个页面中有多个iframe。现在我有一个页面的message事件监听器,它从所有iframe获取消息。我有一个解决方法来了解消息来自哪个iframe。我想分别为每个iframe创建事件监听器。这可能吗? 最佳答案 您必须监听window对象的全局message事件,但您可以使用source过滤源iframeMessageEvent的属性(property).例子:constchildWindow=document.getElementById('test-frame').contentWindow;window.addEven

javascript - 从沙盒 iFrame 到主窗口的 PostMessage,origin 始终为 null

关于javascriptpostMessage事件的事件起源,我有些不明白。这是我的主页:TestOutsidewindow.addEventListener('message',function(event){console.log(event);},false);还有我的iFrame内容Insidevarcounter=1,domain=window.location.protocol+'//'+window.location.host,send=function(){window.setTimeout(function(){console.log('iframesays:',do

html - IE8/9 window.postMessage 不工作,但为什么?

“postMessage”是一个HTML5API,它适用于包括IE8/9在内的所有主流浏览器。我想要做的是从页面创建一个弹出窗口,并能够使用“postMessage”与弹出窗口对话。这适用于除IE8/9之外的所有浏览器。失望!看来IE8/9只允许iframe之间的通信,不支持两个窗口之间的通信,即使是同一层次的窗口。 最佳答案 我发现IE9中的.postMessage()不可靠,除非我使用String。我的解决方法是简单地调用.postMessage(JSON.stringify({object:'data'}))并在中使用JSON

javascript - 跨域postMessage,识别iFrame

我使用postMessage将事件从iframe发送到它的父文档。我可以控制双方,但内容来自两个不同的域。我的简单问题是,我无法在其父回调方法中识别iFrame。实现看起来像这样:在iFrame中:parent.postMessage(JSON.stringify({action:"closeView"}),'*');在父窗口中:window.addEventListener('message',function(event){if(event.origin!=='https://example.com')return;//Parsemessagebacktojsonvarmessag

javascript - React Native WebView postMessage 不起作用

我无法让ReactNativeWebViewpostMessage工作。ReactNative应用程序成功接收到来自Web应用程序的发布消息sendt。但是Web应用程序不接收来自ReactNative应用程序的消息。我的简单网络应用SendpostmessagefromwebPostmessagelogvarlog=document.querySelector("textarea");document.querySelector("button").onclick=function(){console.log("Sendpostmessage");logMessage("Sendin

javascript - postMessage 源 IFrame

我正在开发一个具有跨域iframe的网站,这些iframe使用postMessage调整到正确的高度。我遇到的唯一问题是确定哪个iframe具有哪个高度。我目前设置它的方式是,当一个iframe将其高度发送给父级时,所有iframe的高度都会改变。家长:vareventMethod=window.addEventListener?"addEventListener":"attachEvent";vareventer=window[eventMethod];varmessageEvent=eventMethod=="attachEvent"?"onmessage":"message";e

javascript - 任何好的 HTML5 Javascript postMessage API 调试器?

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭3年前。Improvethisquestion是否有任何好的工具可以让开发人员正确调试使用postMessage在窗口之间发送的消息??或者可能是Firebug的插件?

javascript - 无法在 'postMessage' : https://www. youtube.com 上执行 'DOMWindow' !== http://localhost:9000

这是我收到的错误消息:Failedtoexecute'postMessage'on'DOMWindow':Thetargetoriginprovided('https://www.youtube.com')doesnotmatchtherecipientwindow'sorigin('http://localhost:9000').我见过其他类似的问题,其中目标来源是http://www.youtube.com并且收件人来源是https://www.youtube.com,但没有一个像我的目标是https://www.youtube.com并且源是http://localhost:90

go - Slack API 使用\n 换行在 chat.postMessage (golang) 中不起作用

我正在使用SlackWebAPI将消息发布到Go中的channel。我试图在文本字段中支持多行消息。根据文档,只需添加一个\n就可以,但它不起作用。发布时\n出现在文本中并且没有换行符。这是我使用的代码:funcPostMessage(token,channelName,userName,textstring)error{uv:=url.Values{}uv.Add("token",token)uv.Add("channel",channelName)uv.Add("username",userName)uv.Add("text",text)resp,err:=http.PostFor