我目前正在为网页游戏编写通信框架,通信地图如下所示:
代码如下:
test.php的:
<!DOCTYPE html>
<html>
<head>
<title> Test </title>
<script>
function init()
{
var source = new EventSource("massrelay.php");
source.onmessage = function(event)
{
console.log("massrelay sent: " + event.data);
var p = document.createElement("p");
var t = document.createTextNode(event.data);
p.appendChild(t);
document.getElementById("rec").appendChild(p);
};
}
function test()
{
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function ()
{
if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200)
{
console.log("reciver responded: " + xhr.responseText);
}
}
xhr.open("GET", "reciver.php?d=" + document.getElementById("inp").value , true);
xhr.send();
console.log("you sent: " + document.getElementById("inp").value); …Run Code Online (Sandbox Code Playgroud) 我试图让我的服务器执行一个简单的 bash 脚本:
#!/bin/bash
echo Hello World
Run Code Online (Sandbox Code Playgroud)
将其保存到 /var/www/script(我无缘无故地将其保存到 Web 目录)后,我尝试使用
exec /var/www/script
Run Code Online (Sandbox Code Playgroud)
这失败返回我没有权限执行它,sudo exec这不是一件事,所以我以 root 身份sudo -i运行exec /var/www/script,但我仍然有权限被拒绝。我相当不确定为什么以 root 身份执行它不起作用。我想知道我是不是
A) 使用错误的命令来执行 bash 脚本
B)脚本中的格式不正确
C) 不应该将它保存到 /var/www/
D) 做了一些我什至不知道的其他事情。
如果有帮助,我正在运行 ubuntu 服务器 16.04。
我目前正在构建一个简单的谷歌浏览器扩展来恶作剧我的兄弟.扩展只是删除旧页面并将其替换为从"你没有互联网"页面复制的HTML和CSS,实质上是让用户认为他们没有互联网.以下是注入所有新页面的内容脚本:
var hed = document.head;
var bod = document.body;
document.head.parentElement.removeChild(document.head);
document.body.parentElement.removeChild(document.body);
document.write(/*Copy of "no internet" page source here*/);
Run Code Online (Sandbox Code Playgroud)
这个脚本完美无缺.我不希望发生更改的唯一页面是Google Chrome新标签页.通常排除页面的方法是在内容脚本下的Extensions manifest.json文件中指定它.这是我原来的manifest.json设置:
{
"manifest_version": 2,
"name": "No Internet Extention",
"description": "Make people with this extention think they have no internet",
"version": "1.0",
"content_scripts":
[
{
"matches": ["*://*/*"],
"js": ["bup.js"]
}
],
"permissions":
[
"activeTab",
"https://ajax.googleapis.com/"
]
}
Run Code Online (Sandbox Code Playgroud)
我目前在manifest.json文件content_scripts部分尝试了以下设置,以便排除Chrome新标签页无效:
"matches": ["http://*/*", "https://*/*"]
Run Code Online (Sandbox Code Playgroud)
我认为这会排除它,因为谷歌产品表格上的这个页面告诉我新标签页面的URL是"chrome:// newtab",它不是HTTP:或HTTPS:协议.
我也试过:
"matches": ["*//*/*"]
"exclude_matches": ["chrome://newtab"]
"matches": ["*//*/*"]
"exclude_matches": ["chrome://newtab/*"]
"matches": ["*//*/*"]
"exclude_matches": ["*://newtab/*"]
"matches": ["*//*/*"]
"exclude_globs": …Run Code Online (Sandbox Code Playgroud) 我正在为游戏设计一个标题屏幕.在设计徽标时,我决定在边缘使用彩虹边框:
我想在此之后我想在标题屏幕上用类似的彩虹边框(特别是JButtons)实现我的其余组件.在寻找方法的同时,我遇到了AbstractBorder全班同学.我的问题是,这是否可行,如果是,使用抽象边界类根据组件的大小生成彩虹边框的最有效方法是什么?