2017-01-26 18 views
0

ゲームを作成してチュートリアルを追加しています。私は「レシピ」へのリンクを作ってみましたが、私はそれをウェブサイトと呼んでいますが、それは毎日失効し続けました。だから、私はそれの中に内容を持つ新しいウィンドウを開いてそれを解決する。唯一の問題は、それが適切に作用することです。ウィンドウを開くと、それは2回繰り返されるようです。下のコード例では、すべての行が1行である場合よりも読みやすいように書式を設定しました。代わりに新しいウィンドウが正しく読み込まれない

function newWindow() { 
 
\t myWindow = window.open("", "myWindow", "width=900,height=500"); 
 
\t myWindow.document.write("<!DOCTYPE html> 
 
<html> 
 
<head> 
 
<title> RSS Earth Recipies</title> 
 
<style> 
 
body{ 
 
\t background-color: #f4dc42; 
 
} 
 
</style> 
 
</head> 
 
<body> 
 
<p> 
 
<h3>Shop:</h3> 
 
<br>Fire = 5 Wood<br> 
 
Lumber Jack = 10 Fire and consumes one fire and water per second<br> 
 
House = 50 Wood and 50 Fire<br> 
 
Furnace = 30 Wood and takes one Wood to output on fire<br> 
 
Soldier x 10 = -1 Barracks, 10 water and food and consumes 1 food and water per second<br> 
 
Barracks = 10 houses <br> 
 
Wells = 20 Wood and 5 Food and consumes 1 Food per second but outputs 2 Water per second <br> 
 
Hunter = 10 Wood and 5 Water and consumes 1 Water per second but outputs 2 Food per second<br> 
 
Breeders = 1 house and consumes 1 Fire, Water, and Food per second<br> 
 
<h3>In case you didn't know</h3> 
 
<br><ul> 
 
<li>Every 30 minutes barbarians will raid your civilization and every hour a nation will sweep your civilization.</li> 
 
<li>The number of barbarians can list from 1 to 1000 but for the nation it can go from 1 to 1 Million</li> 
 
<li>This versoin of the game's <b>DESIGN</b> was only made for the 1:1 student laptops that were distributed by onslow conty schools</li> 
 
<li>If you press F12 then you will find various things in the inspector</li> 
 
<li>Press the '/' key and help will pop up</li> 
 
</ul> 
 
</p> 
 
<br> 
 
<hr> 
 
<h1>Tutorial:</h1> 
 
<br> 
 
<ol> 
 
<li>To start things off The first thing you should do is collect wood. You can do this by either pressing the 'Collect Wood' button at the bottom of the webpage or by pressing the 'w' key</li> 
 
<li>Collect at least 30 wood to continue</li> 
 
<li>When you have this collect 30 of both Food and Water. You can do this by pressing the 'Collect Food' and 'Collect Water' buttons at the bottom of the webpage or by pressing the 'q' key for water and the 'o' key for food.</li><li>Now that you have this, we can begin 'automated production' as i like to call it. Quickly press the 'Build Well' and 'Train Hunter' buttons at the bottom of the webpage <b>ONCE</b>. Now your civilization is off to a good start!</li> 
 
<li>When your feeling kind of lost again turn your wood into fire. Remember 5 wood will give you 1 fire.</li><li>So you have that now when you collect 5 fire just go ahead and press the 'Train Lumber Jack' at the bottom of the webpage. Remember: a Lumber Jack will take up 1 food and water per second</li><li>Next when your ready, make sure you have 30 wood and buy a furnace. You can do this by pressing the 'Make Furnace' button at the bottom of the webpage. This will output one fire per second and will destroy one wood per second</li><li>Moving on to houses and barracks. A house will do good for you if you want to get breeders but their also good if you want to train an army. Houses can be converted into barrack if you have the right amount. In order to make a house you have to have 50 wood and fire.</li> 
 
<li>The only reason Barracks are in the game is for the soldiers. Cant have an army with out a storage unit can you? Anyway thats basically the only reasoning you have Barracks. When you buy soldiers you will destroy the amount of Barracks nessesary in order to get troops</li><li>The deal with troops is to give your town a defence against Barbarians, nations, continents, and soon other players! But having troops comes with a cost. The lowest amount of troops you can train at one time is 10 and being that each one accounts for taking in 1 food and water per second your going to need a lot of food and water production!</li> 
 
<li>Now were near the end of the tutorial. This last segment will be about Breeders. Breeders are used for population. Population is shown just above the earth right under the season stats. The reason why these are so useful is because you can convert your current population to either Lumber Jacks or Soldiers. Now in order to convert Population into Soldiers you will need to have at least one Barrack in town. Also keep in mind that the amount that you convert is the amount you have to provide for... Resource wise.</li><h3>Thank you for reading the tutorial! Best of luck!</h3><hr><br><h4><i>Liam Sperry</i></ol></body></html> 
 
}
<a onclick="newWindow()">view recipies</a>

+1

theres複数の直接JavaScript文字列リテラルはありません。 –

答えて

1

この方法で試してみてください。

function newWindow() { 
    myWindow = window.open("", "myWindow", "width=900,height=500"); 
    myWindow.document.write("<!DOCTYPE html><html><head><title> RSS Earth Recipies</title><style>body{ background-color: #f4dc42;}</style></head><body><p><h3>Shop:</h3><br>Fire = 5 Wood<br> Lumber Jack = 10 Fire and consumes one fire and water per second<br> House = 50 Wood and 50 Fire<br> Furnace = 30 Wood and takes one Wood to output on fire<br>Soldier x 10 = -1 Barracks, 10 water and food and consumes 1 food and water per second<br>Barracks = 10 houses <br> Wells = 20 Wood and 5 Food and consumes 1 Food per second but outputs 2 Water per second <br> Hunter = 10 Wood and 5 Water and consumes 1 Water per second but outputs 2 Food per second<br>Breeders = 1 house and consumes 1 Fire, Water, and Food per second<br><h3>In case you didn't know</h3><br><ul><li>Every 30 minutes barbarians will raid your civilization and every hour a nation will sweep your civilization.</li><li>The number of barbarians can list from 1 to 1000 but for the nation it can go from 1 to 1 Million</li><li>This versoin of the game's <b>DESIGN</b> was only made for the 1:1 student laptops that were distributed by onslow conty schools</li><li>If you press F12 then you will find various things in the inspector</li><li>Press the '/' key and help will pop up</li></ul></p><br><hr><h1>Tutorial:</h1><br><ol><li>To start things off The first thing you should do is collect wood. You can do this by either pressing the 'Collect Wood' button at the bottom of the webpage or by pressing the 'w' key</li><li>Collect at least 30 wood to continue</li><li>When you have this collect 30 of both Food and Water. You can do this by pressing the 'Collect Food' and 'Collect Water' buttons at the bottom of the webpage or by pressing the 'q' key for water and the 'o' key for food.</li><li>Now that you have this, we can begin 'automated production' as i like to call it. Quickly press the 'Build Well' and 'Train Hunter' buttons at the bottom of the webpage <b>ONCE</b>. Now your civilization is off to a good start!</li><li>When your feeling kind of lost again turn your wood into fire. Remember 5 wood will give you 1 fire.</li><li>So you have that now when you collect 5 fire just go ahead and press the 'Train Lumber Jack' at the bottom of the webpage. Remember: a Lumber Jack will take up 1 food and water per second</li><li>Next when your ready, make sure you have 30 wood and buy a furnace. You can do this by pressing the 'Make Furnace' button at the bottom of the webpage. This will output one fire per second and will destroy one wood per second</li><li>Moving on to houses and barracks. A house will do good for you if you want to get breeders but their also good if you want to train an army. Houses can be converted into barrack if you have the right amount. In order to make a house you have to have 50 wood and fire.</li><li>The only reason Barracks are in the game is for the soldiers. Cant have an army with out a storage unit can you? Anyway thats basically the only reasoning you have Barracks. When you buy soldiers you will destroy the amount of Barracks nessesary in order to get troops</li><li>The deal with troops is to give your town a defence against Barbarians, nations, continents, and soon other players! But having troops comes with a cost. The lowest amount of troops you can train at one time is 10 and being that each one accounts for taking in 1 food and water per second your going to need a lot of food and water production!</li><li>Now were near the end of the tutorial. This last segment will be about Breeders. Breeders are used for population. Population is shown just above the earth right under the season stats. The reason why these are so useful is because you can convert your current population to either Lumber Jacks or Soldiers. Now in order to convert Population into Soldiers you will need to have at least one Barrack in town. Also keep in mind that the amount that you convert is the amount you have to provide for... Resource wise.</li><h3>Thank you for reading the tutorial! Best of luck!</h3><hr><br><h4><i>Liam Sperry</i></ol></body></html>" 
} 

私はスペースを削除して入力します。それは今働いている。あなたは、このような文字列内で入力することはできません。

var string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis eros lorem. Quisque eu ultricies nunc, et fermentum dui. Integer quis elementum nunc. Nullam a tempus nibh. // just entered here 
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam rutrum tristique tincidunt. Fusce mollis scelerisque mauris, non porttitor est egestas sed. Curabitur elementum, augue nec finibus tincidunt, nunc leo fermentum sapien, quis lobortis enim nunc at justo." 

あなたは、このような文字列を持っており、uはそれをuは、このような+内部の文字列を使用することができますこの方法を使用する場合:

var string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis eros lorem. Quisque eu ultricies nunc, et fermentum dui. Integer quis elementum nunc. Nullam a tempus nibh."+ 
     "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam rutrum tristique tincidunt. Fusce mollis scelerisque mauris, non porttitor est egestas sed. Curabitur elementum, augue nec finibus tincidunt, nunc leo fermentum sapien, quis lobortis enim nunc at justo."; 

に希望をこれは役に立ちます:)

+0

ありがとうございました!私のゲームには多くの混乱があったので、私は本当にこの笑を必要としました。しかし、もう一度、本当にありがとう! –

+0

未来の助けが必要な場合は、私に教えてください:) –

0

使用innerHTMLすでにあります何に書き込むのではなく、HTMLを上書きするあなたの助けをいただき、ありがとうございます。 http://codepen.io/anon/pen/dNVoRd

関連する問題