Embedding Code Help Request

I’m trying to embed a hyperlink to an intranet site (site only works on local area network at our organization). When I use the regular adding hyperlink for web address section, it does not recognize the intranet site address and renders a red exclamation mark and greyed out “Done” button instead of a green checkmark and clickable “Done” button. I contacted Wix help desk and after exchanging back and forth, was met with “its not possible to achieve what you are looking for,” which is basically a bypass/override to that greyed out “Done” button so I can embed the intranet site address. Now, Microsoft Word basic HTML page builder and amateur google sites page builder are able to embed my intranet address hyperlinks, but Wix is supposedly more advanced, but cannot do this? A majority of my links are intranet only addresses. I found out that you can add code on text clicking, so I wanted to embed the intranet address via manual coding. Can this be done? How should the syntax be set up to manually embed a hyperlink upon clicking the text?

I tried:

window.open(url);

But it states: ‘window’ is not defined.

You cannot embed HTML directly in Wix Code. WixCode understands all of Javascript, except for anything that accesses the DOM. This keeps the user from inadvertently “breaking” something. Therefore, the window DOM element cannot be accessed.

Sorry, but I don’t know what you mean by: “the regular adding hyperlink for web address section”.

There are a couple of ways you can embed a link:

By “the regular adding hyperlink for web address section,” I meant selecting text, going to text settings, and clicking the link button:

Unfortunately this happens, a red exclamation mark and greyed out “Done” button that I cannot override.

How do I get the links to open with your ways that you mentioned? Can this happen upon clicking the text?

When I try

$w("#myElement").link = "http://wix.com"

It states:
#myElement” is not a valid selector

@rglee You are getting the error since you apparently don’t have a Button with the ID #myElement. You will need to substitute #myElement with an ID of a button that you have on your page.

@yisrael-wix Can I use code for clicking the text instead of a button?

@yisrael-wix I set #myElement to the ID of the text “text17” and the diagnostic error dot disappeared but it doesn’t work in the live environment.

@rglee As can be seen in the $w.Text API , there is no .link property for a text Component. Furthermore, you are trying to set the non-existent .link property in the onClick event handler which doesn’t do anything.

As I mentioned before, you can use a button for this. For example, I added a button with the ID #button3.

Either set the link for the button from the Editor:


Or you can set the link in code - something like this:

$w.onReady(function () {
    $w('#button3').link = "http://wix.com";
});

With both cases, when you click on the button, you will be sent to the location in the URL.

@yisrael-wix So I tried the button linking and it worked with http://www.wix.com in opening a new page with the site but when I change the link to my intranet address http://staffnet/, it does not even open a page to attempt to load it.

@rglee Are you getting an error message? What happens?

I tried my test with our corporate Intranet and it worked just fine. I would suggest you check with your IT staff regarding your Intranet.

@yisrael-wix Nothing happens when I click it after I replaced the link with different intranet links which all work fine if I open a browser manually at my organization and enter the link manually. The site is Mysite with the “Phone / Paging” button as the button I’m testing.

@rglee I tried with a few of our corporate Intranet URLs and it works fine. Your next stop should be your IT staff. They should be able to help you better regarding this issue.