Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Im making a Text adventure in Html and javascript. I have almost everything I need for it except a way for you to scroll down on the web page while playing.

var start = function(){//The opening room
		while(choice != "door" || "window") {
			document.write("<p>There's a door north of which you sit, south is a small window with a slight breeze coming through</p>");
			document.write("<p> inspect 'door'  inspect 'window'</p>");
			var choice = window.prompt("door or window");
			if(choice == "door"){
				document.write("<p>You stand up, aching in your joints you grunt. Inspecting the door you see, what seems to be, a large iron grated cell door? ''Why would I be in a cell?'' you think to yourself.</p>")
				startDoor()
				break;
			}else if(choice == "window"){
				document.write("<p>You stand up, aching in your joints you grunt. Inspecting the window</p>");
				
				startWindow()
				break;
			}else {
				document.write("<p>Please type the choices as shown</p>");
		};
	};
};


Im trying to put a button in this so before it starts it asks "click to continue" but I can't use confirm or anything because I need then to be able to scroll down. Or If I can make the prompt boxes or confirm boxes not block use of the browser.

This script is being called in the html so it I know it works, just need to let it pause or something somehow

What I have tried:

I've tryed many things but I dont think it was even close to what I need. Ive tried the button click me in both Html and java and have searched the w3schools website extensively.
Posted
Updated 30-Mar-16 15:49pm
v2

1 solution

for scrolling down to the page when the content is filled on the page
use window.scrollTo[^]at the end of your javascript function
JavaScript
window.scrollTo(0,document.body.scrollHeight);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900