How to Link text to a URL using $w.link

I was trying to link some text to a URL using $w(“#text123”).link = “http://www.google.com”;
but when I hover over the text I am not able to click it, what should be done?

Hi Parth,

Welcome to the Wix Code forums.

The Text component does not have a link property. You can create a link using standard HTML in the Text component. Take a look at the $w.Text API for details.

As an example:

$w("#text123").html = '<a href="http://wix.com" target="_blank">Stunning web sites</a>';

Good luck,

Yisrael

Thank you for your helpful posts. I tried the same with a similar code. But there are some error messages. Could you please help me with that?

This is the code:

$w(“#text42”).html = ‘
Set an Opt-Out Cookie for this Browser and this Website
’;

The error messages are:

  1. Unexpected Token
  2. Invalid regular expression flag
  3. Unterminated string constant.

Hi,
It is not possible to add events to tag element in text element.
You have some syntax errors:
This one is without the errors, but still, it wont work

$w("#text1").html = "<a href='#' onclick='document.cookie ='ga-disable-UA-12345-67=true;expires=Thu, 31 Dec 2099 23:59:59 UTC;path=/';window['ga-disable-UA-12345-67'] = true;return false'>Set an Opt - Out Cookiefor this Browser and this Website < /a>";

Roi

Thank you Roi,
How can I implement an Event? Unfortunatelly I can´t code that well that´s why I chose WIX :slight_smile: but know I realize that for opting out of Google Analytics I need some basic coding experience.
I checked out this website form WIX but this is a bit difficult for me:

How could I make an event even from somthing simple as that (without the tag element in a text element):
Click here to opt-out of Google Analytics

Thank you
Artur

Hi Artur,
I guess this article will be useful for you.

Good luck!
Roi

Hi Ron,
I have already implemented Google Analytics to my side with the Google Tag Manager. It´s working fine.
My only problem is to implement this opt-out functionality that Google provides on their website (at the bottom of their page see “example”):

I´m so sorry for being so persistent. But I can´t image that it´s not possible to implement just this simple event on my page:
Click here to opt-out of Google Analytics
I have contacted Wix support for this issue. I have asked different communities in Reddit and Facebook. Nobody could help me :slight_smile:
I would be so happy if somebody who has experience with that issue could help me out or tell me where I can find help with :slight_smile:
Thank you

Just curious is this related to GDRP?

Hi Omid. Yes it is related to GDPR. Here is another post to the same issue: