I am somewhat new to html/php/web-design, and i created an html page that can create a message via hovering over buttons.
<button class="letter" onmouseover="Over(65)">A</button><br>
and the javascript function, Over()
function Over(X){
console.log("Over " + String.fromCharCode(X));
let x = '<div class="out"><p id="text">';
x += document.getElementById("text").innerHTML;
x += String.fromCharCode(X);
x += "</p></div>";
$("div.out").replaceWith(x);
}
put simply, hover over button -> call Over() -> add letter to text
however, while exploring PHP, i got the idea to combine it with another project i had done earlier, using a function that can send chrome OS notifications. (functions at bottom)
My goal for this is to have a column of buttons on the right for letters, 2 buttons on the left for Back and Send. The Back Already works just using
.slice(0, document.getElementById("text").innerHTML.length-1) Now i need to figure out how to make the send function output a notification to all other Windows/tabs i dont know if thats the right word
If this is not enough info or if anyone needs a clearer explanation, i will take feedback <3
function notifyMe(
body = "Notification Body",
title = 'Notification title'
) {
if (Notification.permission !== 'granted')
Notification.requestPermission();
else {
var notification = new Notification('Notification title',{
icon: 'icon.png',
body: "Notification Body",
});
notification.onclick = function() {
window.open('https://stackoverflow.com/');
};
}
}
You really shouldn't be using PHP and JavaScript. To make it easier, it is just one or the other. But, you can create a php tag in HTML by saying <script type=text/php> I am pretty sure, and have them communicate on the same page.
You could just use element.onmouseover = function() { // YOUR CODE HERE } and then send out a remote that gets picked up on php.
I don't use php, so sorry if I can't answer how to pick the remote up on php.