Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to set cookie information for a page?
#3
Thanks for your patient answers, questions 1, 2, 3 are now clear.
The fourth question, in PowerBuilder 9.0 can not accept the postMessage sent by the OnWebMessageReceived event, I am exactly in accordance with the official website of the DEMO to test, since you can not send screenshots, please allow me to send the code:

HTML PAGE CODE:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="StyleSheet" href="WebMessage.css" type="text/css">
<script>
function sendString() {
const textData = document.getElementById("data");
if (textData && window.chrome.webview) {
window.chrome.webview.postMessage(textData.value);
}
}
function sendJSON() {
const textData = document.getElementById("data");
if (textData && window.chrome.webview) {
let msg = {
name: "Bob",
age: 38,
comment: textData.value
};
window.chrome.webview.postMessage(msg);
}
}

window.chrome.webview.addEventListener('message', (event) => {
const textData = document.getElementById("data");
if (textData) {
if (typeof event.data === 'object' || typeof event.data === 'null') {
textData.value = JSON.stringify(event.data);
} else {
textData.value = event.data;
}
}
});
</script>
</head>
<body>
<section class="container">
<p>Send data between HOST application and control via messages</p>
<textarea id="data">Text that you want to sent to the application hosting the browser control.</textarea>
<div>
<span>
<button id="postString" onclick="sendString();">Post String</button>
</span>
<span>
<button id="postJSON" onclick="sendJSON();">Post JSON</button>
</span>
<div>
</section>
</body>
</html>

PB CODE:

event oncreatewebviewcompleted(long hresult);this.object.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0"
this.object.EventsUseHexadecimal = true
this.object.WebMessageEnabled = true
end event

event onwebmessagereceived(string uri, string messageasjson, string messageasstring);
messagebox("postmessage",messageasjson)
mle_1.text = messageasstring
end event
Reply


Messages In This Thread
RE: How to set cookie information for a page? - by Leeson - 2022-09-22, 06:33:17

Forum Jump:


Users browsing this thread: 1 Guest(s)