Ben
Ben

Reputation: 257

Is it possible to have external link with jquery call?

Is it possible to somehow create a link with a jQuery function call?

For example: I send a client an e-mail with a link to a page. but i want to also include a jQuery function that will (just for example) pop up some div on that page (which the link was linking to) or (just another example) change some css classes on that page or so... those are just examples. the goal is to be able to fire a jQuery function after the linked page was loaded.

Upvotes: 0

Views: 42

Answers (1)

roberrrt-s
roberrrt-s

Reputation: 8210

Give the URL a parameter.

Example URL:

www.ben.com/site/hello.html&popup=true;

Catch the &popup=true; with a .split() on the & and the =, and take the parameters. Send a popup with jQuery afterwards.

Example code:

function popUp() {
    var href = window.location.href;
    var param = href.split('&');
    var value = param[param.length - 1].split('=');
    if (value[0] === "popup" || value[1] === "true") {
        popUpMessage();
    }
}

Upvotes: 1

Related Questions