//*** Email Link ***// dojo.connect(map, 'executeIdentifyTask', function (result) { // Add a link into the InfoWindow Actions panel var emailLink = dojo.create("a", { "class": "action email", "innerHTML": "Email Comments", "href": "javascript:void(0);" }, dojo.query(".actionList", map.infoWindow.domNode)[0]); console.log(emailLink); // Register a function to be called when the user clicks on // the above link dojo.connect(emailLink, "onclick", function (evt) { var feature = map.infoWindow.getSelectedFeature(); var url = window.location; var emailLink = "mailto:emailaddress@email.com?subject=Comments:%20" + feature.attributes.ID + "&body=Comments on Landmark:%20ID:%20"+ feature.attributes.ID +" @ " + window.location; window.location.href = emailLink; }); });
Solved! Go to Solution.
Hey, Vern,
I've modified your code to create a container element if it doesn't already exist and then add the link after emptying the container.
//*** Email Link ***// dojo.connect(map, 'executeIdentifyTask', function (result) { if (!dojo.byId("emailLink")) { dojo.create("span", { id: "emailLink" }, dojo.query(".actionList", map.infoWindow.domNode)[0]); // Add a link into the InfoWindow Actions panel var emailLink = dojo.create("a", { "class": "action email", "innerHTML": "Email Comments", "href": "javascript:void(0);" }, "emailLink", "only"); console.log(emailLink); // Register a function to be called when the user clicks on // the above link dojo.connect(emailLink, "onclick", function (evt) { var feature = map.infoWindow.getSelectedFeature(); var url = window.location; var emailLink = "mailto:emailaddress@email.com?subject=Comments:%20" + feature.attributes.ID + "&body=Comments on Landmark:%20ID:%20" + feature.attributes.ID + " @ " + window.location; window.location.href = emailLink; }); } });
Let me know if it doesn't work out for you.
--Alan
Hey, Vern,
I've modified your code to create a container element if it doesn't already exist and then add the link after emptying the container.
//*** Email Link ***// dojo.connect(map, 'executeIdentifyTask', function (result) { if (!dojo.byId("emailLink")) { dojo.create("span", { id: "emailLink" }, dojo.query(".actionList", map.infoWindow.domNode)[0]); // Add a link into the InfoWindow Actions panel var emailLink = dojo.create("a", { "class": "action email", "innerHTML": "Email Comments", "href": "javascript:void(0);" }, "emailLink", "only"); console.log(emailLink); // Register a function to be called when the user clicks on // the above link dojo.connect(emailLink, "onclick", function (evt) { var feature = map.infoWindow.getSelectedFeature(); var url = window.location; var emailLink = "mailto:emailaddress@email.com?subject=Comments:%20" + feature.attributes.ID + "&body=Comments on Landmark:%20ID:%20" + feature.attributes.ID + " @ " + window.location; window.location.href = emailLink; }); } });
Let me know if it doesn't work out for you.
--Alan