Skip to content

Tag: javascript

play random video on each visit/refresh with iFrame javascript

How do I create a random video to play every time a user visits/reloads the page with Javascript? For example, if one person were to go onto my domain, the iFrame would try to load any of the .mp4 files inside of my media file directory where it has like 4 different .mp4 videos. Here is my code below. Code:

Export a function from a JavaScript file

I am trying to make a component in React that is just a function I am importing my function in another component like this but I get an error saying: How do I export a js file that is just a function? Answer Since you export it as default you have to import it like so: Edit: Another issue with

Show/Hide elements JavaScript

I am attempting to create forms that are hidden on each page. I figure I had to make a separate functions for each button and form that I wanted to hide. So my logic was to use the same code on separate JS pages but changing the id and function names on each JS page. However when I do so,

Styling rendered iframe in react

As the title says, I’m trying to style an iframe from rendered content in React. I am needing to set the iframe’s width and height to an aspect ratio, which typically requires wrapping the iframe in a specific div. Since it’s being pulled in from post content data, I don’t have the abi…

syntax error unexpected toke in if statement in js

I am receiving a syntax error with unexpected token < at line 14 when i try to run this script in my browser. What i am trying to do is open my classes 5 minutes before class and still open when ran all the way up to 5 minutes before the next class. Answer date.getTime() doesn’t return the time of