JavaScript Problem: Passing a JavaScript Value Between HTML Pages

Поділитися
Вставка
  • Опубліковано 26 лют 2019
  • In this tutorial we are going to look at passing a value from one HTML page to another. We will use two techniques: localstorage and the query string. The value we are going to pass is the number of milliseconds so that we can determine elapsed time.
    For more resources on JavaScript:
    www.allthingsjavascript.com
    Access to EVERY course (get 2 months free): www.skillshare.com/r/profile/...
    Courses offered on Udemy at a discount (access from my site): allthingsjavascript.com/course...
    Tutorials referred to in this video:
    local storage: • The Ins and Outs of lo...
    indexedDB: • Getting Started with i...
    coersion: • JavaScript Questions: ...
    Formatting Time with Date object: • JavaScript Problem: Fo...
    Tracking Elapsed Time: • JavaScript Tip: Tracki...
    Determining Days Between Dates: • Determining the Number...
    #javascript #AllThingsJavaScriptLLC

КОМЕНТАРІ • 41

  • @nathanheath1328
    @nathanheath1328 4 роки тому +1

    This solved the problem I was having for my personal project ! Thank you !

  • @ntigirishari
    @ntigirishari 4 роки тому +1

    This has been reaaaally helpful!! Thank you :-)

  • @scottk5083
    @scottk5083 3 роки тому

    Thank you so much for this!

  • @neeharikachinimilli9720
    @neeharikachinimilli9720 2 роки тому

    Thank you so much .I have been watching lots of videos for redirecting my html page .But your lecture video made my day.It helped me in completing my project .Thanks a lot 🤗🤗

  • @Rajeshkumar-jb9pf
    @Rajeshkumar-jb9pf 5 років тому +6

    Awesome! Please post videos on js Design patterns...

  • @aabirsabil4393
    @aabirsabil4393 Рік тому +1

    Thanks for this video

  • @codewithdoge
    @codewithdoge 4 роки тому

    I just wanted to take out the heading text of one page and show it on other html that this the heading how to do so

  • @RagHelen
    @RagHelen 5 років тому +5

    About the replacing with regex: Is there nothing less costly, like splitting or find and slice in Python?

    • @AllThingsJavaScript
      @AllThingsJavaScript  5 років тому

      There are several solutions since the data is a string. Here is a tutorial on split: ua-cam.com/video/IMm1GsOUGvQ/v-deo.html

  • @williamvv1587
    @williamvv1587 4 роки тому

    Thank you so much! This solved my problem perfectly! :)

  • @Musfiq77
    @Musfiq77 4 роки тому

    Thank you sir

  • @Jan_Jan_
    @Jan_Jan_ 2 роки тому

    This solved my problem! 👏Thank you so much! :D

  • @SK-xr7up
    @SK-xr7up 4 роки тому

    very helpful....

  • @chchan8977
    @chchan8977 5 років тому

    Thank you for the awesome tutorial. How to reset the elapsed time in every refresh or attempt?

    • @AllThingsJavaScript
      @AllThingsJavaScript  5 років тому

      To reset the elapsed time, you could get the date again at the same time you reset the variable for tracking the keys.

  • @jeogk
    @jeogk 4 роки тому

    What do we put in the span tag of present5.html to replace the static text? When I run it, I get "Here is the amount of time that has passed: TIME"

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 роки тому +1

      That is handled by the code in app3.js. Just make sure it has the right id 'time'.

  • @jetmonkey9474
    @jetmonkey9474 4 роки тому

    I'm having trouble getting the technique to work. I want once the script is executed for the other page to be permanently edited, is there a way to do that with this technique or is that not possible?

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 роки тому

      Not exactly sure what you mean by "permanently edited". Are you saying you want to change the underlying HTML page? That is not possible from the client side, but if you are trying to permanently change something perhaps that data should be coming from a database??

  • @jeguestudio5686
    @jeguestudio5686 4 роки тому

    Good video but i have any question. We can't change the value propertye from a html element? For example: var htmlElement = document.getElementById("idElement"); htmlElement.value = "someValue";
    It didn't work for me as it did work before.

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 роки тому

      You can do this. What type of HTML Element was it? You probably want to use innerHTML for changing the contents.

  • @blueskyandseablue
    @blueskyandseablue 4 роки тому

    This video was really useful! I tried with erb file instead of html, but it did not work... It worked fine with html files. Would be very nice if you let me know how to fix it!

  • @anips3192
    @anips3192 4 роки тому

    Hello sir, Awesome tutorial :) I have a doubt
    @10:31 in line 12 instead of function(){init();} i did init() directly and it is not working and what s the difference between the two.
    I am pretty new to js i started just today so I don't understand the difference

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 роки тому

      There are a couple of differences, but the main difference is that whenever you put parentheses after a function it causes it to invoke. So if you put in init() with parens, it will invoke immediately not in response to the event. You could put just init (without parens). In my code a defined an anonymous function and then had that function invoke init. Though not necessary sometimes I do that because of issues that can be encountered with the this keyword in JavaScript or if I want to do more than one function in response to the event.

    • @anips3192
      @anips3192 4 роки тому

      thank you sir tht clarified my doubt . I tried init and it worked bery well

  • @johanbondennysveen4418
    @johanbondennysveen4418 3 роки тому

    Can you use the LocalStorage -technique to pass a score from a game (game.html) over to a highscore table(highscore.html) on another file?

    • @AllThingsJavaScript
      @AllThingsJavaScript  3 роки тому +1

      Local storage works per a domain. So if it is on the same domain you can access it.

    • @johanbondennysveen4418
      @johanbondennysveen4418 3 роки тому

      @@AllThingsJavaScript the thing is I am only working local on my pc. I dont have a public domene. But the two html files are under in the same folder.

    • @AllThingsJavaScript
      @AllThingsJavaScript  3 роки тому

      @@johanbondennysveen4418 I would set up a local server. There are so many ways to do this. If you are using VS Code, there is a server extension. You can do it with node as well: ua-cam.com/video/GqAK_dMi-P8/v-deo.html and many other ways.

    • @johanbondennysveen4418
      @johanbondennysveen4418 3 роки тому

      @@AllThingsJavaScript yeah, I am using VS Code but were thinking about doing it with node. I am not that experienced tho. But, thanks for your answers! I will check out your video too:)

  • @pritichhetri135
    @pritichhetri135 4 роки тому

    It's a nice video! I have a form, I want the value entered in that form to be displayed on another page! Is it possible using Javascript?? If yes, please give me the link of a video about that, please?

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 роки тому +1

      I don't have a tutorial for the specific situation you mentioned, but just grab the value entered in the form and pass it using one of the techniques in this tutorial.

  • @bilawalhussain4557
    @bilawalhussain4557 5 років тому +1

    Thanks man It works !! I was facing some dynamic data storage between 2 pages but you helped me out from it ....
    Thumbs Up and A Subscribe for you :)

    • @AllThingsJavaScript
      @AllThingsJavaScript  5 років тому

      Functional programming is difficult to address in a single tutorial. I've done a course on it: www.udemy.com/functional-programming-in-javascript-a-practical-guide/?couponCode=UA-cam19

    • @AllThingsJavaScript
      @AllThingsJavaScript  5 років тому

      Sorry, replied to the wrong comment with the functional course. :-)

    • @bilawalhussain4557
      @bilawalhussain4557 5 років тому

      @@AllThingsJavaScript Its okay xDD Thanks for comment btw !

  • @jaerap8585
    @jaerap8585 4 роки тому

    You are a fucking genius, you solved my problem with such a good explanation, Thank you very much!