Home » Javascript » javascript to check a link for string & launch modal

javascript to check a link for string & launch modal

Posted by: admin October 29, 2018 Leave a comment

Questions:

Have a page containing links.

When a link is clicked I want Javascript (or other) to check if the link contains (e.g. cheese)

If if does, then a modal should launch displaying the link.

example:

http://mylink/just-normal/ — when this clicked, should proceed as normal

http://mylink/with-cheese/ — when this clicked, should launch modal

http://mylink/another-link/ — when this clicked, should proceed as normal

http://mylink/other-link/ — when this clicked, should proceed as normal

Modal should display the full link.

Any assistance is appreciated.

Answers: