Skip to main content
AliMaleki
Level 4
Feb 17, 2016 3:10 PM UTC
Solved

Capture Text Portion of a Website Link

I'm capturing clicks on website links but can't figure out how to capture the link text.

I'm using the Custom Page Code section of an Event Based Rule

Sample link: <a class="schoolLink" href="http://www.example.com" target="_blank">Our New Website</a>

I know how to get the HREF:

var Link = this.getAttribute('href');
_satellite.notify("Link: "+Link);

Result: "SATELLITE: Link: http://www.sample.com"

How can I get the TEXT ("Our New Website")?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
ParitMittal
ParitMittalAccepted solution
Level 10
Feb 18, 2016 4:39 AM UTC

Hi Ali, 

As per our understanding for getting the text "Our New Website" , you have to use "this.innerHTML"  . Please see the below sample code for more details .

var LinkName = this.innerHTML;
_satellite.notify("Linkname: "+LinkName);

please let us know in case of any questions or queries.

Thanks & Regards

Parit Mittal

2 replies

ParitMittal
ParitMittalAccepted solution
Level 10
Feb 18, 2016 4:39 AM UTC

Hi Ali, 

As per our understanding for getting the text "Our New Website" , you have to use "this.innerHTML"  . Please see the below sample code for more details .

var LinkName = this.innerHTML;
_satellite.notify("Linkname: "+LinkName);

please let us know in case of any questions or queries.

Thanks & Regards

Parit Mittal

Translate
AliMaleki
AliMalekiAuthor
Level 4
Feb 18, 2016 2:14 PM UTC

Excellent! Thanks for the help Parit.

Ali

Translate