/    Sign up×
Community /Pin to ProfileBookmark

Browser model

Hi, i am maiking a model of internet explorer for a university project but im having some problems. instead of typing a url into a textbox the user must enter a word. this word is then displayed on the screen. i have this bit working but im struggling with the back and forward buttons. i need to store these words in a stack so that they can be accessed with the back and forward buttons. also, the stack must also be displayed in a table cell. any suggestions on how to do all of this would be appreciated.

Thanks

Jo

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@cgishackJan 15.2008 — Are you sure you have the right forum?

this is Java[B]Script[/B], did you want Java?
Copy linkTweet thisAlerts:
@shd05017authorJan 15.2008 — no, definatly javascript. ? .
Copy linkTweet thisAlerts:
@cgishackJan 15.2008 — Sorry. i was just confused about making a "model of internet explorer" i guess.
Copy linkTweet thisAlerts:
@cgishackJan 15.2008 — you can maybe store the back and forward words in an array.
<i>
</i>var keyWords = new Array();
keyWords.push("cars");
keyWords.push("school bus");
keyWords.push("foo");
keyWords.push("bar");



Drew
Copy linkTweet thisAlerts:
@shd05017authorJan 15.2008 — dont worry, im confused too. i am new to javascript. cant seem to get my head around it. its more a browser within a browser except it doesnt have to go to websites. just display what you type in the 'url' box. the code you gave for that bit worked really well. thanks for that. its just the back and forward arrays im struggling with now.
Copy linkTweet thisAlerts:
@drhowarddrfineJan 15.2008 — So you are making a simulator.
Copy linkTweet thisAlerts:
@shd05017authorJan 15.2008 — yes. do you have any idea on how i would do the back and forward buttons?
Copy linkTweet thisAlerts:
@shd05017authorJan 15.2008 — i think it has to store words that the user has entered. so everytime they type in a word and click 'go', it stores it in an array. only i have no idea how to do this.
Copy linkTweet thisAlerts:
@cgishackJan 15.2008 — Maybe these snippets will help, or maybe not..

They more control the browser....

[B]back[/B]
<i>
</i>&lt;input type=button value="Back" [B]onClick="history.go(-1)"[/B]&gt;


Forward:
<i>
</i>&lt;input type=button value="Forward" [B]onClick="history.forward()[/B]"&gt;




Drew
Copy linkTweet thisAlerts:
@cgishackJan 15.2008 — I whipped this up for you,

I might help you understand how to manage your array.
<i>
</i>
&lt;html&gt;
&lt;head&gt;

&lt;title&gt;Words&lt;/title&gt;


&lt;script&gt;

var wordArray = new Array();
var currentPosition = 0;

function addWord()
{
var word = document.getElementById("word");
var displayWord = document.getElementById("displayWord");
displayWord.innerHTML = word.value;

<i> </i>wordArray[currentPosition] = word.value;
<i> </i>currentPosition++;
<i> </i>word.focus();
}

function showNextWord()
{
if (currentPosition &lt; wordArray.length)
{
currentPosition+=1;
var displayWord = document.getElementById("displayWord");
displayWord.innerHTML = wordArray[currentPosition -1];
}

}

function showPrevWord()
{
if (currentPosition &gt;1)
{
currentPosition -= 1;
var displayWord = document.getElementById("displayWord");
displayWord.innerHTML = wordArray[currentPosition -1];
}
}

&lt;/script&gt;


&lt;/head&gt;

&lt;body&gt;



&lt;input type="text" id="word" /&gt;&lt;input type="button" id="next" value="Submit" onclick="addWord();" /&gt;
&lt;br /&gt;

&lt;input type="button" id="previous" value="&amp;lt;- Previous" onclick="showPrevWord();" /&gt;
&lt;input type="button" id="next" value="Next -&amp;gt;" onclick="showNextWord();" /&gt;


&lt;br /&gt;

&lt;span id="displayWord"&gt; &lt;/span&gt;
&lt;/body&gt;
&lt;/html&gt;



just cut and paste into your browser.

Drew
×

Success!

Help @shd05017 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...