2017-09-22 11 views
-2

したがって、HTML/JavaScriptでランダムクォートジェネレータを作成しようとしています。さて、無作為な日本語のエモーティコンジェネレータの詳細。javascriptでランダムなクォートジェネレータを作成しようとしましたが、関数呼び出しの値が定義されていないと言われました

私は最近まで、私のnewEmoticon関数が定義されていないと言っているところまで問題はなかった。ここで

はコードです -

<html> 
    <head> 
    <style> 
     <meta charset="utf-8"> 
     <title> Japanese Emoticon Generator </title> 
     <meta name= “description” content=“A Japanese emoticon generator for all your Japanese emoticon needs.”> 
    </style> 
    </head> 
    <body> 
    <h1>Japanese Emoticon Generator </title> 
    <br> 
    <button onclick="newEmoticon()">Generate!</button> 
    <div id="emoticonDisplay"> 
    </div> 
    <h3>All emoticons credit of <a href="http://japaneseemoticons.me/">japaneseemoticons.me</a> and <a href="https://textfac.es/">textfac.es</a></h3> 

<script> 
var emoticons = [ 

't(〃⊙౪ ∩=)/', '-(๑☆‿ ☆#)ᕗ', '((☆^⌓ ^☆)╭', 
'((o⊙Σ ⊙。)m', '「(;´Σ `〃)ヘ', '「(#Φ益 Φo)∩', 
'「(=>o≦=)ノ', '~(。☉︵ ಠ@)>', '~(๑ñ﹏ ⊙☆)ノ', 
'⊂(o•ิ▂ ñ*)づ', '┗(●-﹏ `。)づ', '╭ (oㅇ‿ o#)ᕗ 
╮', '(☆-_ ⊙;)ゞ', '╰(๑^⌓ ^=)ᕗ', 'ヾ (;・﹏ •̀☆)b 
ヾ', '(✿>﹏ ⊙〃)ノ', 'ヽ(♡≧m´。)っ', 'm(★⊙¬ ㅇ ●)ლ', 
'O(*@д o#)づ', 'O(o^O `;)人', 'Σ(@°xº♡)/', 
'Σ(♡@﹏ @☆)ノ”', 'Σ(๑+⌓ o。)シ', 'φ(●⌒へ ⌒〃)o', 
'ψ(๑∩⌓ ∩ ●)y', 'щ (*ㅇ△ Φ☆)ノ', 'ლ (#`ロ^;)>', 
'ᕙ (;`⊥ ^★)┐', 'ᕙ (✿⊙へ ⊙〃)', 'ᕙ (❁^д ^*)っ', 
'ᕦ(;*Σ ⌒❁)ᕗ', 'へ(●`ㅅ `☆)ლ', 'へ(。•ิ‿ -〃)', 
'┗(•̀へ •́ ╮)', '╭(✖_✖)╮', '(͡° ͜ʖ ͡°)', '∠(ᐛ 」∠)_ ', 
'(゚⊿゚)', 'ᕕ(ᐛ)ᕗ', '_へ__(‾◡◝)>', '(ᐛ)و', 
'(◞・౪・) ', '¯\_༼ ି ~ ି ༽_/¯', '¯\_༼ ಥ ‿ ಥ ༽_/¯', 
'¯\_(⊙_ʖ⊙)_/¯', '¯\_| ✖ 〜 ✖ |_/¯', '¯\_▐ ☯ ︿ ☯ ▐_/¯', 
'¯\_╏ ՞ ︿ ՞ ╏_/¯ ', '¯\_(⊙︿⊙)_/¯ ', '¯\_ȌᴥȌ_/¯', 
'¯\_ʘᗜʘ_/¯', '¯\_ȌᴥȌ_/¯'  , '(;`ヘ´)', '((( ̄へ ̄井)', 
'(`へ´*)ノ', '( ̄へ ̄)', '(。-`へ´-。)', 'ε-(‘ヘ´○)┓', 
'(≧ヘ≦ )', 'ρ( ̄ヘ ̄ メ)', '(*`・へ・´*)', 
'(((0へ0)', '(*`へ´*) 彡3', '(`へ′)' 
]; 
//More will be gradually added in the future. Be patient. 

function newEmoticon() { 
    var random = Math.floor(Math.random() * (emoticons.length)); 
    document.getElementById('emoticonDisplay').innerHTML = emoticons[random]; 
} 

</script> 
</body> 
</html> 

私はGoogleの検索とコードのやり直しを試みたが、私は結果を得ていません。

ありがとうございました。

+0

はStackOverflowのへようこそしようとし、将来的にはこのようなものを探すために、ブラウザの開発ツールを使用し、23行目にエラーがあります。あなたのコードは**ここに**掲載する必要があります。このサイトには、ソースコードを直接ホスティングするための十分な機能があり、外部サイトとの関連付けを断つことは明白な目標です。 – Pointy

+0

編集しました。私に言ってくれてありがとう! – Trent

+0

実際の問題は、あなたの顔文字のリストに構文エラーがあることです。あなたが(おそらく) "終端されていない文字列リテラル"について見ているそのエラーは、あなたの関数が定義されていない理由です。 – Pointy

答えて

2

あなたはこの

<html> 
    <head> 
    <style> 
     <meta charset="utf-8"> 
     <title> Japanese Emoticon Generator </title> 
     <meta name= “description” content=“A Japanese emoticon generator for all your Japanese emoticon needs.”> 
    </style> 
    </head> 
    <body> 
    <h1>Japanese Emoticon Generator </title> 
    <br> 
    <button onclick="newEmoticon()">Generate!</button> 
    <div id="emoticonDisplay"> 
    </div> 
    <h3>All emoticons credit of <a href="http://japaneseemoticons.me/">japaneseemoticons.me</a> and <a href="https://textfac.es/">textfac.es</a></h3> 
<script> 
var emoticons = [ 

't(〃⊙౪ ∩=)/', '-(๑☆‿ ☆#)ᕗ', '((☆^⌓ ^☆)╭', 
'((o⊙Σ ⊙。)m', '「(;´Σ `〃)ヘ', '「(#Φ益 Φo)∩', 
'「(=>o≦=)ノ', '~(。☉︵ ಠ@)>', '~(๑ñ﹏ ⊙☆)ノ', 
'⊂(o•ิ▂ ñ*)づ', '┗(●-﹏ `。)づ', '╭ (oㅇ‿ o#)ᕗ ╮', 
'(☆-_ ⊙;)ゞ', '╰(๑^⌓ ^=)ᕗ', 'ヾ (;・﹏ •̀☆)b ヾ', 
'(✿>﹏ ⊙〃)ノ', 'ヽ(♡≧m´。)っ', 'm(★⊙¬ ㅇ ●)ლ', 
'O(*@д o#)づ', 'O(o^O `;)人', 'Σ(@°xº♡)/', 
'Σ(♡@﹏ @☆)ノ”', 'Σ(๑+⌓ o。)シ', 'φ(●⌒へ ⌒〃)o', 
'ψ(๑∩⌓ ∩ ●)y', 'щ (*ㅇ△ Φ☆)ノ', 'ლ (#`ロ^;)>', 
'ᕙ (;`⊥ ^★)┐', 'ᕙ (✿⊙へ ⊙〃)', 'ᕙ (❁^д ^*)っ', 
'ᕦ(;*Σ ⌒❁)ᕗ', 'へ(●`ㅅ `☆)ლ', 'へ(。•ิ‿ -〃)', 
'┗(•̀へ •́ ╮)', '╭(✖_✖)╮', '(͡° ͜ʖ ͡°)', '∠(ᐛ 」∠)_ ', 
'(゚⊿゚)', 'ᕕ(ᐛ)ᕗ', '_へ__(‾◡◝)>', '(ᐛ)و', 
'(◞・౪・) ', '¯\_༼ ି ~ ି ༽_/¯', '¯\_༼ ಥ ‿ ಥ ༽_/¯', 
'¯\_(⊙_ʖ⊙)_/¯', '¯\_| ✖ 〜 ✖ |_/¯', '¯\_▐ ☯ ︿ ☯ ▐_/¯', 
'¯\_╏ ՞ ︿ ՞ ╏_/¯ ', '¯\_(⊙︿⊙)_/¯ ', '¯\_ȌᴥȌ_/¯', 
'¯\_ʘᗜʘ_/¯', '¯\_ȌᴥȌ_/¯'  , '(;`ヘ´)', '((( ̄へ ̄井)', 
'(`へ´*)ノ', '( ̄へ ̄)', '(。-`へ´-。)', 'ε-(‘ヘ´○)┓', 
'(≧ヘ≦ )', 'ρ( ̄ヘ ̄ メ)', '(*`・へ・´*)', 
'(((0へ0)', '(*`へ´*) 彡3', '(`へ′)' 
]; 
//More will be gradually added in the future. Be patient. 

function newEmoticon() { 
    var random = Math.floor(Math.random() * (emoticons.length)); 
    document.getElementById('emoticonDisplay').innerHTML = emoticons[random]; 
} 

</script> 
</body> 
</html> 
+0

それは働いた!どうもありがとうございます! – Trent

-1

これは単なるフォーマット上の問題でした。矢印の一部が別の行に分割されました。

<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <style> 
 
     <meta charset="utf-8"> 
 
     <title> Japanese Emoticon Generator </title> 
 
     <meta name= “description” content=“A Japanese emoticon generator for all your Japanese emoticon needs.”> 
 
    </style> 
 
    </head> 
 
    <body> 
 
    <h1>Japanese Emoticon Generator </title> 
 
    <br> 
 
    <button onclick="newEmoticon()">Generate!</button> 
 
    <div id="emoticonDisplay"> 
 
    </div> 
 
    <h3>All emoticons credit of <a href="http://japaneseemoticons.me/">japaneseemoticons.me</a> and <a href="https://textfac.es/">textfac.es</a></h3> 
 

 
<script> 
 
var emoticons = [ 
 

 
't(〃⊙౪ ∩=)/', \t '-(๑☆‿ ☆#)ᕗ', \t '((☆^⌓ ^☆)╭', 
 
'((o⊙Σ ⊙。)m', \t '「(;´Σ `〃)ヘ', \t '「(#Φ益 Φo)∩', 
 
'「(=>o≦=)ノ', \t '~(。☉︵ ಠ@)>', \t '~(๑ñ﹏ ⊙☆)ノ', 
 
'⊂(o•ิ▂ ñ*)づ', \t '┗(●-﹏ `。)づ', \t '╭ (oㅇ‿ o#)ᕗ╮', 
 
'(☆-_ ⊙;)ゞ', \t '╰(๑^⌓ ^=)ᕗ', \t 'ヾ (;・﹏ •̀☆)bヾ', 
 
'(✿>﹏ ⊙〃)ノ', \t 'ヽ(♡≧m´。)っ', \t 'm(★⊙¬ ㅇ ●)ლ', 
 
'O(*@д o#)づ', \t 'O(o^O `;)人', \t 'Σ(@°xº♡)/', 
 
'Σ(♡@﹏ @☆)ノ”', \t 'Σ(๑+⌓ o。)シ', \t 'φ(●⌒へ ⌒〃)o', 
 
'ψ(๑∩⌓ ∩ ●)y', \t 'щ (*ㅇ△ Φ☆)ノ', \t 'ლ (#`ロ^;)>', 
 
'ᕙ (;`⊥ ^★)┐', \t 'ᕙ (✿⊙へ ⊙〃)', \t 'ᕙ (❁^д ^*)っ', 
 
'ᕦ(;*Σ ⌒❁)ᕗ', \t 'へ(●`ㅅ `☆)ლ', 'へ(。•ิ‿ -〃)', 
 
'┗(•̀へ •́ ╮)', \t '╭(✖_✖)╮', '(͡° ͜ʖ ͡°)', \t '∠(ᐛ 」∠)_ \t ', 
 
'(゚⊿゚)', 'ᕕ(ᐛ)ᕗ', \t '_へ__(‾◡◝)>', \t '(ᐛ)و', 
 
'(◞・౪・) \t ', '¯\_༼ ି ~ ି ༽_/¯', \t '¯\_༼ ಥ ‿ ಥ ༽_/¯', 
 
'¯\_(⊙_ʖ⊙)_/¯', \t '¯\_| ✖ 〜 ✖ |_/¯', \t '¯\_▐ ☯ ︿ ☯ ▐_/¯', 
 
'¯\_╏ ՞ ︿ ՞ ╏_/¯ \t ', '¯\_(⊙︿⊙)_/¯ \t ', '¯\_ȌᴥȌ_/¯', 
 
'¯\_ʘᗜʘ_/¯', \t '¯\_ȌᴥȌ_/¯' \t \t , '(;`ヘ´)', '((( ̄へ ̄井)', 
 
'(`へ´*)ノ', '( ̄へ ̄)', '(。-`へ´-。)', 'ε-(‘ヘ´○)┓', 
 
'(≧ヘ≦ )', 'ρ( ̄ヘ ̄ メ)', '(*`・へ・´*)', 
 
'(((0へ0)', '(*`へ´*) 彡3', '(`へ′)' 
 
]; 
 
//More will be gradually added in the future. Be patient. 
 

 
function newEmoticon() { 
 
    var random = Math.floor(Math.random() * (emoticons.length)); 
 
    document.getElementById('emoticonDisplay').innerHTML = emoticons[random]; 
 
} 
 

 
</script> 
 
</body> 
 
</html>

+0

しましたが、「顔文字」が定義されていないと言っていました。だから私はスクリプトのタグ全体を頭の中に動かし、同じ問題が発生した。 – Trent

+1

@Trent申し訳ありませんが、私は結論に飛びました。私は答えを訂正しましたが、私が編集している間、ジェームスは正しく答えました。彼らの答えを受け入れてください。 – WizardCoder

関連する問題