是否可以从一段html代码中更改JavaScript中的字体?是否可以从HTML中更改JavaScript的字体?
我想“强制”JS显示本地字体,但我不能更改JS(它不是我的脚本,它是混乱的)。
JS由纵横字谜程序生成,只允许您在将文件导出到网页时在“时间新罗马”和“无衬线”之间进行选择。一切都以小写输出,我可以使用“text-transform:uppercase”来修复所有字母大写。为什么不能用字体做同样的事情? (是的,它可以在网页上的其他地方使用)。
下面是完整的代码:<! - 我在这里的评论 - >
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta NAME="Generator" CONTENT="Crossword Compiler (www.crossword-compiler.com)">
//this is my stylesheet to call @font-face.
<link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" />
//this is from the original code. I've only added 'fatalityregular':
<STYLE TYPE="text/css"
{ "font-family: fatalityregular, Arial, Times, sans-serif";
}></STYLE>
//this whole section looks like this when you export the puzzle to web:
<!--
BODY, .Clues, .GridClues { font-size: -3pt; font-family: 'fatalityregular', Arial, Times, sans-serif;}
-->
<!--
.PuzTitle {
font-size: 15pt; color: #800000; font-weight: bold;
}
.CopyTag {
font-size: 10pt; color: #000000
}
-->
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#ffffff">
//this is what I use to fix Times/Arial. With MYFONT I won't need this (it's all uppercase):
<span style="text-transform: uppercase">
<script src="CrosswordCompilerApp/jquery.js"></script>
<script src="CrosswordCompilerApp/raphael.js"></script>
<script src="CrosswordCompilerApp/crosswordCompiler.js"></script>
<script src="MyCrossword.js"></script> //This is where I want MYFONT to be used.
<script>
$(function(){
$("#CrosswordCompilerPuz").CrosswordCompiler(CrosswordPuzzleData,null,
{SUBMITMETHOD:"POST",PROGRESS : "" , ROOTIMAGES: "CrosswordCompilerApp/CrosswordImages/" });});
</script>
<div id="CrosswordCompilerPuz"></div>
</span>
</BODY>
</HTML>
仅供参考,''是HTML注释。因此浏览器会忽略任何内容。 – forgivenson
您应该尝试使用css而不是javascript来更改页面的任何风格。正如@forgivenson所提到的,你头脑中的css规则已被注释掉。您应该将注释标签切换到样式标签,就像这样'' – mpallansch
谢谢你的回答。我已经使用fontsquirrel生成我的字体。它在stylesheet.css中。它在任何地方都能正常工作,除了填字游戏(由我创建填字游戏的程序生成)之外。难道这里的问题是JS会覆盖其他所有东西吗?就像我说过的,当我将填字游戏导出到网络文件时,我必须选择Times New Roman或Sans Serif。我应该改变applet脚本中的某些内容吗?我不知道如何解决这个问题.- – camcom