Giter Club home page Giter Club logo

mdn / beginner-html-site-scripted Goto Github PK

View Code? Open in Web Editor NEW
259.0 49.0 297.0 170 KB

A single-page website created to help complete beginners learn HTML with JS added to help beginners learn JavaScript. Supports https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/JavaScript_basics

Home Page: https://mdn.github.io/beginner-html-site-scripted/

License: Creative Commons Zero v1.0 Universal

CSS 19.29% JavaScript 35.27% HTML 45.44%
html javascript learning

beginner-html-site-scripted's Introduction

Beginner HTML (HyperText Markup Language) site scripted

A simple one page website created to help complete beginners learn HTML basics, which in this repo has also had some script added to help beginners learn JavaScript basics. The scripting is explained over the course of the JavaScript basics course.

Live site

Run the example live.

beginner-html-site-scripted's People

Contributors

bsmth avatar caugner avatar chrisdavidmills avatar dpanov avatar mozilla-github-standards avatar mrbrain295 avatar psylone avatar siraj-samsudeen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beginner-html-site-scripted's Issues

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please see Mozilla-GitHub-Standards or email [email protected].

(Message COC001)

TypeError: myImage is null

I'm trying to learn JS basics, however also got stuck with this error
TypeError: myImage is null (as it was mentioned in closed issue)
in the line:
myImage.onclick = function() {

At the same time, if I put the script just in js console in browser, it works. Maybe it's connected with Visual Studio Code, I'm writing in. I've tried both relative and absolute paths.

prompt()

What information was incorrect, unhelpful, or incomplete?

The function setUserName() calls itself if the user enters nothing or an empty string.
If the user next enters a non-empty string, myName will be whatever was entered on the previous try, namely null or the empty string.
This problem can be avoided by repeating the prompt command, rather than calling the whole function again, but it would be nice to have an explanation of what is causing it.

What did you expect to see?

x

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

Issues with Adding a personalized Welcome Message

Hello,

I am currently beginning the Odin Project and have progressed to the JavaScript basics portion. Following this guide (https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/JavaScript_basics)
After spending some time attempting to get the code to prompt you for a name / give the user an individualized welcome message with no success, I am here.

I believe that I followed the instructions to the letter but have been unable to get either the prompt function, welcome message, or change user button to work. I even tried to copy and past the code but the issue still persists.

I will attempt to copy and paste the code below and see if you folks could help spot the error!
From: index.html:
'''

<title>My test page</title>

A delightful trip into the Green Mountains with Dorian Yablin!

A photograph of Dorian and I a top Jay Peak Mountain during a week long ski trip!

Here Dorian and I were cheering on top of Jay Peak Mountain because of the beautiful weather and fantastic ski conditions we were experiencing!

  • A week long get away with a condo on the mountain!
  • One of our many trips together that leaves me filled with joy and happiness!

Jay Peak Resort!
Change user

<script src="scripts/main.js"></script> '''

Here is the main.js:
var myImage = document.querySelector('img');

myImage.onclick = function() {
var mySrc = myImage.getAttribute('src');
if(mySrc === 'images/jay_peak_trip.jpg') {
myImage.setAttribute ('src','images/vienna_trip.jpg');
} else {
myImage.setAttribute ('src','images/jay_peak_trip.jpg');
}
}

var myButton = document.querySelector('button');
var myHeading = document.querySelector('h1');

function setUserName() {
var myName = prompt('Please enter your name.');
localStorage.setItem('name', myName);
myHeading.textContent = 'Welcome!, ' + myName;
}

if(!localStorage.getItem('name')) {
setUserName();
} else {
var storedName = localStorage.getItem('name');
myHeading.textContent = 'Welcome Back! ' + storedName;
}

myButton.onclick = function() {
setUserName();
}

Sorry if this is just a wall of syntax, but I simply don't know how else to go about finding this error. Any and all tips / advice is appreciated! Thank you for your time!

The MyButton.onlclick does not work

Hi

My assumption is that when I press the Change user button it will rerun the setUserName function. However the no promt come up to do so. I have used a getelementID to carry this out and it works. However in this case it keeps repeating every single time I reload the page.

I am completely new to Javascript but appreciate any feedback you can provide.

Hijry time

What information was incorrect, unhelpful, or incomplete?

Nuthing

What did you expect to see?

Bsjsj

Do you have any supporting links, references, or citations?

Non

Do you have anything more you want to share?

Non

The thought about the designing

Well, firstly this is a pretty cool website, and the user can type the name before enter the website. I think the blue parts on the left and right can change to some information or features of Mozilla to show to the users. Also for the user name, the user can type anything and even any number or symbol, so if that can be changed should be better.

Issues with Adding a personalized Welcome Message

Hello,

I am currently beginning the Odin Project and have progressed to the JavaScript basics portion. Following this guide (https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/JavaScript_basics)
After spending some time attempting to get the code to prompt you for a name / give the user an individualized welcome message with no success, I am here.

I believe that I followed the instructions to the letter but have been unable to get either the prompt function, welcome message, or change user button to work. I even tried to copy and past the code but the issue still persists.

I will attempt to copy and paste the code below and see if you folks could help spot the error!
From: index.html:

<title>My test page</title>

A delightful trip into the Green Mountains with Dorian Yablin!

A photograph of Dorian and I a top Jay Peak Mountain during a week long ski trip!

Here Dorian and I were cheering on top of Jay Peak Mountain because of the beautiful weather and fantastic ski conditions we were experiencing!

  • A week long get away with a condo on the mountain!
  • One of our many trips together that leaves me filled with joy and happiness!

Jay Peak Resort!
Change user

<script src="scripts/main.js"></script>

Here is the main.js:
var myImage = document.querySelector('img');

myImage.onclick = function() {
var mySrc = myImage.getAttribute('src');
if(mySrc === 'images/jay_peak_trip.jpg') {
myImage.setAttribute ('src','images/vienna_trip.jpg');
} else {
myImage.setAttribute ('src','images/jay_peak_trip.jpg');
}
}

var myButton = document.querySelector('button');
var myHeading = document.querySelector('h1');

function setUserName() {
var myName = prompt('Please enter your name.');
localStorage.setItem('name', myName);
myHeading.textContent = 'Welcome!, ' + myName;
}

if(!localStorage.getItem('name')) {
setUserName();
} else {
var storedName = localStorage.getItem('name');
myHeading.textContent = 'Welcome Back! ' + storedName;
}

myButton.onclick = function() {
setUserName();
}

Sorry if this is just a wall of syntax, but I simply don't know how else to go about finding this error. Any and all tips / advice is appreciated! Thank you for your time!

myImage === null

I got error messages indicating that myImage wasn't being set to the name of the image.

This was confirmed by an error trap (if(myImage === null ) {alert(myImage is null) .

I finally copied the GitHub version which replicate the previous bad behavior.
The errant code appears to be:
var myImage = document.querySelector('img');

Has anyone else had this experience, or more importantly a fix?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.