Question

Specify a URL in a Label


Userlevel 3
Badge +13

Hi all,

 

Quickie, I have a Label Control with some text in, but I want to include a URL in the text for users to click on, can this be done?

 

Text example: For more information, goto http://www.google.com and read the policy

 

I noticed the hyperlink and URL controls, but cant seen to get them to be incorporated into the same box/label.

 

Thanks,


19 replies

I was able to accomplish with a data label and an expression tied to it:

 

Instead of typing out Google in the display name field, you can type out the full URL as a display name.

Userlevel 3
Badge +13

Dave,

 

As always, my hat is off to you, thanks again buddy.

 

Just one daft thing though, when the form is run, the data lable displays the URL is a lighter shade of Kermit the Frog and makes your eyes fuzzy (see below snippet). Is there any way of keeping the text before the URL stay as black, but the URL display name to be blue so that it stands out?

 

Thanks!!!

 

 

Answer 1: Seperate out the normal text with a label, and put the hyperlink in its own control so you can format the style.

 

Answer 2: It might be possible to throw in some xml coding, however the expression starts to flake out when you add too many conditions.

Userlevel 3
Badge +13

As XML coding is scary...

 

I tried option 1 with a seperate control for the URL and choose text colour blue, it still displays it as kermit green.

 

If I apply a background colour, it shows the background in the correct colour but still shows the text colour as kermit green (no matter what text colour i choose)

 

 

I dropped a label control with "Please go to: " and a hyperlink control.  I was able to format the hyperlink control with colors.  

Userlevel 3
Badge +13

Got the colour working now with the hyperlink control, how did you get the text and the hyperlink controls on the same line?

I'm using wordwrap as the text goes onto two lines, but the hyperlink is appears underneath rather than next to the text

 

 My URL appears on the next line, rather than next to the data label...

Control placement is something you will get more use to over time.

 

Main reason is that the cell you have your controls in are too tight.  You can take your cursor and move the walls of the cell out, however it will also move the entire column.  I will either drag the column size and move it over a bit, OR I will just put one control in a cell, then place the other one in the next cell over.  

 

 

One more thing that I will play with...and you'd have to be careful with this one, is if you click the cell the toolbar at the top will give you a couple of options of merging the cell to either the right or bottom.  I would play with that one on a test view to get use to it:

Userlevel 3
Badge +13

Thanks for the advice Dave, and i've had some fun (in a frustrating way) with the add column and merge columns over the last week or so, so i know how they work now.

 

Dunno how, but managed to get it working. I used a table, added two labels + URL controls and fits fine on 2 lines.... I won;t be touching that line EVER again....

 

Nice one Dave!

 

Userlevel 3
Badge +13

Sorry for digging up an old thread, but i've just used this same technique on another form and noticed that if I use an Expression to concat the wording and URL, the formatting of the URL (i.e. Blue) does not carry across when used in an Expression. Secondly when clicking on the URL (within the Expression) when the form is running, the link opens up in the same page. I want it to open in a seperate Window (which it will if in a hyperlink control), but won't if used in an expression.

 

Any ideas?

Userlevel 6
Badge +10

Dear,

 

I suggest to change technique, set the below as expression:

 

 

<style type="text/css">a:link {COLOR: #0000FF;}a:visited {COLOR: #800080;}a:hover {COLOR: #FF0000;}a:active {COLOR: #00FF00;}</style><span>goto</span><a href="javascript&colon;q=(document.location.href);void(open
('http://Google.com?url='+escape(q),'_self','resizable,location,menubar,toolbar,scrollbars,status'));">google</a>
<span>and read the policy</span>

 

Userlevel 3
Badge +13

Hi Mustafa,

 

I did this, but when you click on the link, it opens up on the same window. I need the URL to open in a seperate window.

 

Possible?

Userlevel 6
Badge +10

Dear,

 

sorry it's my fault, Change _self to _blank

Userlevel 3
Badge +13

Hi,

 

That does work if you have IE with tabs, because it opens the new window as a Tab.

 

Is it possible to make it come up as a Pop-up Window, rather than a new tab? -That way it should work on any browser?

 

Appreciate your help with this by the way

Userlevel 6
Badge +10

Dear,

 

try this

 

<style type="text/css">a:link {COLOR: #0000FF;}a:visited {COLOR: #800080;}a:hover {COLOR: #FF0000;}a:active {COLOR: #00FF00;}</style><span>goto</span><a href="javascript&colon;q=(document.location.href);void(open
('http://Google.com?url='+escape(q),'newwindow' ,'width=300, height=250','resizable,location,menubar,toolbar,scrollbars,status'));">google</a>
<span>and read the policy</span>

Note: edit the height and the width to get the size you want.

 

 wish it helps

 

 

Userlevel 3
Badge +13

Mustafa,

 

One last request, how do you make the TEXT size 16?

At the moment i have edited the data label, added the expression with your code. I then went to the data label control STYLES and changed font to 16.

When i then run the view, the URL appears in font 16, but the text before it is size 8.

 

Can you point out which bit resizes the font in your code for the text before and after the URL part?

 

Thanks

Userlevel 6
Badge +10

Dear,

Inside the css add this:

Span{

Font-size:16pt;

}

 

 

Check where I added it:

 

<style type="text/css">span{font-size:16pt;} a:link {COLOR: #0000FF;}a:visited {COLOR: #800080;}a:hover {COLOR: #FF0000;}a:active {COLOR: #00FF00;}</style><span>goto</span><a href="javascript&colon;q=(document.location.href);void(open
('http://Google.com?url='+escape(q),'newwindow' ,'width=300, height=250','resizable,location,menubar,toolbar,scrollbars,status'));">google</a>
<span>and read the policy</span>

 you can change pt TO px 

Userlevel 3
Badge +13

 Hi Mustafa,

 

Tried your font code and doesn't work. It doesn't resize the line at all.

 

Userlevel 6
Badge +10

Dear,

 

take this instead:

 

<style type="text/css">a:link {COLOR: #0000FF;}a:visited {COLOR: #800080;}a:hover {COLOR: #FF0000;}a:active {COLOR: #00FF00;}</style><span style="font-size:16px;">goto</span><a href="javascript&colon;q=(document.location.href);void(open('http://Google.com?url='+escape(q),'newwindow' ,'width=300, height=250','resizable,location,menubar,toolbar,scrollbars,status'));">google</a><span style="font-size:16px;">and read the policy</span>

 notcie that I added the style in the <span> 

Userlevel 6
Badge +10

Hi Sharpharp1,

 

try the following :

 

<style type="text/css">a:link {COLOR: 000FF;}a:visited {COLOR: 800080;}a:hover {COLOR: FF0000;}a:active {COLOR: 0FF00;}</style><span style="font-size:16px;">goto</span><a href="javascript&colon;q=(document.location.href);void(open('http://Google.com?url='+escape(q),'newwindow' ,'width=300, height=250,resizable=1','location,menubar,toolbar,scrollbars,status'));">google</a><span style="font-size:16px;">and read the policy</span>

wish it helps

Reply