I am looking to use jquery to search for a certain string that gets tagged onto the end of the page url after a user submits a form.
The url looks like
https://somerandomsite.com/?page_id=1423#wpcf7-f1448-p1423-o1
The only part of the string that stays consistent is the “wpcf7” so I am looking to target that with jquery and if it finds it run some code. Maybe use window.location.pathname somehow.
Any help would be much appreciated.
============================================
I got it everyone, thanks for your help. I don’t think I was very clear in explaining the problem so I apologize.
if(document.location.hash.substr(1,5) === 'wpcf7'){
$('#formalert').css('display', 'block');
That part is called the hash and is referenced as:
This includes the
#character itself, so you have to skip that:To get the first part behind it:
Update
The final condition would be this: