是否可以從一段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