Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用tampermonkey中的按钮切换HTML_Html_Tampermonkey - Fatal编程技术网

使用tampermonkey中的按钮切换HTML

使用tampermonkey中的按钮切换HTML,html,tampermonkey,Html,Tampermonkey,我一直在尝试让脚本在切换按钮时切换一段HTML, 但到目前为止我还没能让它工作 let newImg5 = document.createElement("img"); newImg5.src = "https://www.pcinvasion.com/wp-content/uploads/2016/12/discord.jpg"; newImg5.style = `position: absolute; bottom: 15px; left: 15px; z-index: 100000; wi

我一直在尝试让脚本在切换按钮时切换一段HTML, 但到目前为止我还没能让它工作

let newImg5 = document.createElement("img");
newImg5.src = "https://www.pcinvasion.com/wp-content/uploads/2016/12/discord.jpg";
newImg5.style = `position: absolute; bottom: 15px; left: 15px; z-index: 100000; width: 50px; height: 50px; cursor: pointer;`;
document.body.prepend(newImg5);
newImg5.addEventListener("click", () => {
       toggle.html <iframe src="https://discordapp.com/widget?id=68awdawdawdawds8&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0"></iframe>
});

听起来你想做这样的事情:

let newImg5 = document.createElement("img");
newImg5.src = "https://www.pcinvasion.com/wp-content/uploads/2016/12/discord.jpg";
newImg5.style = `position: absolute; bottom: 15px; left: 15px; z-index: 100000; width: 50px; height: 50px; cursor: pointer;`;
document.body.prepend(newImg5);

/* create iframe */
let iframe = document.createElement('iframe');
iframe.setAttribute('id', 'iframe');
iframe.setAttribute('src', 'https://discordapp.com/widget?id=68awdawdawdawds8&theme=dark');
iframe.setAttribute('width', '350');
iframe.setAttribute('height', '500');
iframe.setAttribute('allowtransparency', 'true');

/* Make iframe appear on click */
newImg5.addEventListener("click", () => {
       document.body.append(iframe);
});

toggle.html我知道,我正在努力找到一个可以工作的。看起来大多数片段都可以工作,但是现在iFrame没有出现,尝试了改变它的位置,它将附加html,但这也没有什么不同。