Thanks, on another issue, concerning the document.write object and method, when using it, if you wish to use it to write “multiple” lines of text at different times in one script, do you use it only once or do have to use it each time you need to write the text?
but that is the only source which I am understanding so I have to deal with things a little differently when it comes to modern day JS just so you understand what I am dealing with, I haven’t gotten to var yet, I am following the course as structured. So, would it be possible for you to break down any further what what you have written please?
If so, my questions, using your example would be:
1] To begin using the write method, should I use this var html = ‘’;
every time?
2] What are the 3 dots for between each line?
3] Should I always write this html += ‘<p>Some text</p>’; when referring to text?
4] If you are saying I should stay away from the document.write then why use this document.write(html); at the end?
late here now, will check back in the morning for any answers, thanks!
Sure thing. I just had a look at your source, and it appears that the “return” parts from what you quoted, are actually the image that was used on the web page to indicate a new line.
I won’t get in to the pros/cons of document.write just yet. Instead, here’s something about what you were asking, the formatting of a statement.
The code from your sample page should instead be:
write("Today's date is " +
(RightNow.getMonth()+1)+
"-" + RightNow.getDate() + "-"
+ RightNow.getFullYear() + ".
You entered this Web Page at exactly: "
+ RightNow.getHours() +
":" + RightNow.getMinutes() + " and "
+ RightNow.getSeconds() +
" seconds");
That could also be all on one line:
document.write("Today's date is " + (RightNow.getMonth()+1)+ "-" + RightNow.getDate() + "-" + RightNow.getFullYear() + ". You entered this Web Page at exactly: " + RightNow.getHours() + ":" + RightNow.getMinutes() + " and " + RightNow.getSeconds() + " seconds");
Or it could be split up like this:
document.write(
"Today's date is " +
(RightNow.getMonth() + 1) + "-" +
RightNow.getDate() + "-" +
RightNow.getFullYear() +
". You entered this Web Page at exactly: " +
RightNow.getHours() + ":" +
RightNow.getMinutes() + " and " +
RightNow.getSeconds() + " seconds"
);
Notice how it’s easier to understand that last example? The main purpose of formatting is to reduce confusion when you and other people read your code. One of the best ways to reduce confusion, is to follow a style guide or code conventions for your code. These help to enforce good practices, so that confusion is reduced to a minimum.
A better online learning resource that you may want to consider has been receiving high praise lately. You may want to check out Eloquent JavaScript instead.
Sure. Let’s go back to the code that you posted, which started all of this.
document.write("Today's date is "
return+ (RightNow.getMonth()+1)+
return"-" + RightNow.getDate() + "-"
return+ RightNow.getFullYear() + ".
returnYou entered this Web Page at exactly: "
return+ RightNow.getHours() +
return":" + RightNow.getMinutes() + " and "
return+ RightNow.getSeconds() +
return" seconds")
Whereever you see the word “return” in there, they should not be there. Those are the images on the web page that look like this:
Those don’t belong in your code, so when you copy the code from their web page, you’ll need to watch out for those images and get rid of the extra text that they naughtily add to the code.
Note though that there is also a keyword called return, that’s used to return a value from a function. See Javascript Basics Part 3 for an example of that, in the validateForm function.
So in all, watch out for on the web page, and be sure to remove what they add.
The same section of the documentation page says that directories is now obselete.
It was supported in old web browsers up to IE6, but not in more recent ones.
There’s little that I can add to the information that you get from there.
Not really what I am asking, let me try another way, what “location box” is this referring to, the new pop up window? If yes then what “current URL” is this referring to? Does this all mean whether or not the pop up window should show the URL of the page you are reading from?
[indent]Obsolete in Gecko 2
Obsolete synonym of personalbar. In IE, it rendered the Links bar. Supported in Gecko up to 1.9.2 and in IE up to 6.[/indent]
I elaborated earlier in saying that it only works in old web browsers like IE6. Anything newer than that and it doesn’t work.