How Do You Get the URL Parameters and Append to Href or Src of Another Element?

Do you want to grab the url parameters and pass them to a button href or iframe src? This is common when you are running a paid ad campaign to a landing page that links to a form on another page. You want to track the source of the form submission by duplicating the url… Read more »

Continue Reading

Category: Code Snippets

Console Log JavaScript Objects to See Data Structure [code snippet]

When working with JavaScript objects and arrays it is often tricky to reference the correct index of the data you need. These console functions allow you to visually see the structure so that job is a bit easier. Writes your object as a data table and also dropdown menu

Writes your object as a… Read more »

Continue Reading

Category: Code Snippets

Uncaught TypeError: Cannot read property ‘msie’ of undefined when upgrading to WordPress 5.5

Recently when upgrading an older site to WordPress 5.5 I noticed a javascript error in the console that read Uncaught TypeError: Cannot read property ‘msie’ of undefined. If you have a plugin or script that relied on an older version of jQuery it will no longer work because WordPress updated their jQuery version. In order… Read more »

Continue Reading

Category: Code Snippets

Throttle or Delay JavaScript Functions When Window is Resized [code snippet]

Underscore.js has a popular method for throttling and debouncing functions to prevent them from firing multiple times when a window is resized. I found this delay function that works for times when you don’t need to load the entire underscore library to achieve a similar effect.

Continue Reading

Category: Code Snippets

How to Change Favicon with JavaScript

This code comes in handy when you don’t have access to the head of the page and need to change the favicon.

 

Continue Reading

Category: Code Snippets

How to Fire a jQuery Function When the Page is Loaded and Resized

When building responsive websites you often want to run a script when the page loads. But when you resize the window the layout breaks. You can use the on method to run your code if the page loads or has been resized.

Source

Continue Reading

Category: Code Snippets

How to Visually See What Your jQuery Selection is Selecting

I was recently working on form validation and wanted to mark a.form-group as successful if it contained a particular icon inside the label. The icon was set using PHP depending if the data existed in the database. I was writing .prev() and .parent() to try and select the wrapping .form-group but it wasn’t working and… Read more »

Continue Reading

Category: Code Snippets / Tutorials

How to Prevent One Word Lines (widow orphan) In Website Paragraphs

I am often adding padding to the left and right of paragraphs to force copy down to prevent one word on a line. Or even worse, I add <br> to a word on the line above to prevent the word by itself. But this causes issues with responsive design because the <br> changes position breaking… Read more »

Continue Reading

Category: Code Snippets

Trigger HubSpot Popup Form on Page Load or CTA Click

HubSpot provides the ability to display a pop up form with various triggers (exit intent, after 7 seconds, etc.) But what if you want to show it immediately or when a button is clicked? Below is some javascript to help achieve this functionality.

 

Continue Reading

Category: Code Snippets

Open All Links to PDF files in a New Window

This finds all of the links pointing to PDF files and opens them in a new window. If you are using Chrome, you will need to enable popups for this to work.

 

Continue Reading

Category: Code Snippets