I’m using the window.atob(‘string’) function to decode a string from base64 to a string. Now I wonder, is there any way to check that ‘string’ is actually valid base64? I would like to be notified if the string is not base64 so I can perform a different action. Answer If “valid” means “only has base64 chars in it” then check
Get column from a two dimensional array
How can I retrieve a column from a 2-dimensional array and not a single entry? I’m doing this because I want to search for a string in one of the columns only so if there is another way to accomplish this please tell me. I’m using the array defined this way: At the end the size of this array is
Is there an easy way to determine which hemisphere a user is in?
I’m working on a project which includes seasonal content, and we’re thinking of determining the user’s location to work out what season it is for them. The obvious way of doing this is to Geo-locate their IP, then grab the latitude. > 0 is Northern hemisphere, and < 0 is Southern. I’m happy to go that way – though it
Get element inside element by class and ID – JavaScript
Alright, I’ve dabbled in JavaScript before, but the most useful thing I’ve written is a CSS style-switcher. So I’m somewhat new to this. Let’s say I have HTML code like this: How would I change Hello world! to Goodbye world!? I know how document.getElementsByClassName and document.getElementById work, but I would like to get more specific. Sorry if this has been
How to disable event links in FullCalendar when using Google Calendar feed?
I am using FullCalendar library to load events in my calendar from Google Calendars. Unfortunately after events have been added to the calendar, they are clickable. When you click on the event you are automatically redirected to the Google Calendars page to view that specific event, or if you have enaught access rights – to directly edit it. While this
Converts minutes into days, week, months and years
Let’s suppose I have a number which represents the minutes passed from the start time to now. I wan to create a function which returns the years, months, week and days corresponding to the minutes I am passing to that function. Here an example: What is the best way to achieve the result? Answer Maybe like this?
How can I prevent refresh of page when button inside form is clicked?
I have an issue while using buttons inside form. I want that button to call function. It does, but with unwanted result that it refresh the page. My simple code goes like this On clicking the button, the function gets called with page refreshed, which resets all my previous request which affects the current page which was result of the
How to show a linked page as the content of a table element in my case?
I have made a HTML table. Suppose I have a link, for example, link to www.nokia.com , can I show the linked page as a content of the table element when “click me” has clicked? and how to do that? Answer Maybe you could use <iframe> and some jQuery for the job. Example: jQuery: HTML:
JavaScript Number Split into individual digits
I am trying to solve a math problem where I take a number e.g. 45, or 111 and then split the number into separate digits e.g. 4 5 or 1 1 1. I will then save each number to a var to run a method on. Does anyone know how to split a number into individual digitals? For example I
Loading external javascript in google chrome extension
I’m writing a Google Chrome extension which manipulates the current page (basically adds a button). In my content script, I want to load the Facebook Graph API: However, the script doesn’t seem to added to body. Here’s the console log: Any ideas on what I’m doing wrong? Answer The issue is that the JavaScript inside the content scripts runs in