gpt4 book ai didi

html - 更改 Iframe 中的文本颜色

转载 作者:行者123 更新时间:2023-11-28 19:03:02 24 4
gpt4 key购买 nike

我想在我的博客中包含一个 iframe,问题是我的背景是黑色的,iframe 中的文本颜色也是黑色。

无论如何,我可以在不访问原始内容的情况下更改 iframe 文本的颜色?

最佳答案

<html>
<head>
<script type="text/javascript">
function InitEditable ()
{

var editor = document.getElementById ("editor");

var editorDoc = editor.contentWindow.document;
var editorBody = editorDoc.body;

// turn off spellcheck


if (editorBody.contentEditable === undefined) { // Firefox earlier than version 3
if (editorDoc.designMode !== undefined) {
// turn on designMode
editorDoc.designMode = "on";
}
}
else {
// allow contentEditable
editorBody.contentEditable = true;
}

}





function ToggleBold ()
{
editorDoc.execCommand ('bold', false, null);
}
function ToggleItalic ()
{
editorDoc.execCommand ('italic', false, null);
}
function SetRed () {
//sets foreground color
editorDoc.execCommand ('foreColor', false, "#ff0000");
}
function Delete () {
editorDoc.execCommand ('delete', false, null);
}
</script>
</head>
<body onload="InitEditable ();">
First, write and select some text in the editor.
<br />
<iframe id="editor" src="F:\EXAMPLE\JAVA\FILE\SURESHMNG.txt"></iframe>
<input type="textarea" id="ta"></textarea>
<br /><br />
You can use the following buttons to change the appearance of the selected text:
<br /><br />
<button onclick="ToggleBold ();">Bold</button>
<button onclick="ToggleItalic ();">Italic</button>
<button onclick="SetRed ();">Set to red</button>
<button onclick="Delete ();">Delete</button>
</body>
</html>

关于html - 更改 Iframe 中的文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4874309/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com