Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Invoking JavaScript in a SHDocVw.WebBrowser from QM?
#5
This sounds exactly right - but I'm not getting it to work. I'm hoping that I'm missing something simple here. I'm using the WM_COPYDATA example from the forums to send the message (I wasn't sure if I should be sending them to the window or the html control).

Code:
Copy      Help
Function [b]RadFusionSendMsg3[/b] [help1][/help1]
[code]int w1=win("RadFusionRDialog" "#32770")

int c=child("" "Internet Explorer_Server" w1 0x0 "accName=http://emiswd0vm1/RadFusionR/RadFusionRClient.aspx") ;; 'http://localhost:63351/RadF...'


SHDocVw.WebBrowser wb._getcontrol(id(3 w1))
str location = wb.LocationURL
out F"Browser location {location}"

str groupName = "RFGroupName"
str clientType = "Impax Client"
str commandName = "This is a test, only a test from RadFusion"

str javascriptString = F"testSendCommand(''{groupName}'', ''{clientType}'', ''{commandName}'','''');"

COPYDATASTRUCT cds
cds.dwData=4194305
cds.lpData=javascriptString
cds.cbData=javascriptString.len+1


SendMessage(w1 WM_COPYDATA 0 &cds)
SendMessage(c WM_COPYDATA 0 &cds)[/code]

Then - in JavaScript I've set up some listeners:
Code:
Copy      Help
window.addEventListener('message', function (e) {
                    alert("window Message arrived " + e.data);
                }, false);
document.addEventListener('message', function (e) {
                    alert("document Message arrived " + e.data);
                }, false);
I've also created an iFrame in the window and set up listeners on that as well (I'm using IE10 - as I've been looking around it sounds like there is a problem sending messages to windows but it works sending to iFrames). But I never get the alerts from the web pages.

My questions:
  • Is WM_COPYDATA a reasonable message type to send?
  • What is the right entity to send the message to (I'm assuming it's the 'c' above)
  • Is there a similar mechanism for achieving the same end (sending JavaScript functions with arguments to an existing web dialog). Note that the dialog might be hidden and I don't know if this means that certain UI interactions won't work.

Thanks!


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)