【发布时间】:2014-06-20 00:17:28
【问题描述】:
我遇到了使用 vba 访问 iframe 的内容窗口的问题。使用 iframe.domain = document.domain 检查时,框架位于同一域中。以下是我到目前为止所尝试的。我阅读了所有网站,但找不到解决方法。任何其他简化同域/跨域消息传递的方法都是非常值得赞赏的。
Dim ie As New InternetExplorer
Dim objshell, objshellwindows
Dim doc As MSHTML.HTMLDocument
Dim doc1 As MSHTML.IHTMLDocument
Dim iframe As MSHTML.HTMLIFrame
Set objshell = CreateObject("Shell.Application")
Set objshellwindows = objshell.Windows
For Each ie In objshellwindows
If InStr(ie.LocationURL, "http://www.example.com/examples/camera/html/index.html") > 0 Then
Set doc = ie.document
For Each iframe In doc.getElementsByTagName("IFRAME")
Set doc1 = iframe.contentWindow.document '---Access Denied/ Permission Denied Error
Next
End If
Next
【问题讨论】: