/    Sign up×
Community /Pin to ProfileBookmark

Very simple document.writeln issue

Well its simple to you. And hello.

Here is my code. very straight forward.

[code]
<SCRIPT LANGUAGE=JAVASCRIPT>
<!–

var r=Math.floor(Math.random()*100*100)

var userName = prompt(“Sign in:”,””);
document.writeln(“Logged in: ” + userName + “”);
document.write(‘<br />’);
document.writeln(“Wallet: &#163;” + r + “” );
//–>
</SCRIPT>[/code]

I’m having trouble being able to code corecting adding <font>, and <br> into the code. what i would like is Logged In and wallet to be slightly bigger then the resualts displayed.

iv been tyring for a hour ?

Also if some one would be so kind to change my login so it sets a cookie i would be very greatful. refreshing would begin to annoy a user with the prompt. i been trying for an hour ?

Thank you

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ZeroKilledNov 07.2008 — writeln method add a line break at the end of the content that print. however, that line break is only present in the source code. as you may know, browser ignore extra white space. also, some kind of white space as the carriage return (or Enter key) are treated as a common white space.

so, because document.write(ln) method write the content in the source code context (that is, it don't simply display the content directly on the browser's canvas or viewport) you can include HTML code in the string:
<i>
</i>document.writeln("&lt;font size='4'&gt;Logged in: " + userName + "&lt;/font&gt;[color='red']&lt;br /&gt;[/color]");


notice the red text is a <br /> tag. is simply as putting html code as part of the string.
Copy linkTweet thisAlerts:
@crabbyauthorNov 07.2008 — Thank you very much you have been most helpful.
×

Success!

Help @crabby 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.17,
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,
)...