mailto: problem - html

I'm trying to set up the following mailto: link:
<a href='mailto:info#example.com?subject=Testing&body=http://www.google.com?foo=1&bar=2'>Send mail</a>
However the second argument (bar) is cut off because it is seen as an argument of the mailto link and not the link I'm putting in the body. I tried & but it does the same thing since it's being rendered into the link.

What about something like this :
<a href='mailto:info#example.com?subject=Testing&body=http%3A%2F%2Fwww.google.com%3Ffoo%3D1%26bar%3D2'>Send mail</a>
ie, urlencoding the whole body field, to make sure nothing causes any problem ?

Use "%26" instead or use urluncoding like suggested in another answer. For PHP rawurlencode works well.
<a href='mailto:info#example.com?subject=Testing&body=http://www.google.com?foo=1%26bar=2'>Send mail</a>

Try putting the value for body into quotes like:
'mailto:info#example.com?subject=Testing&body="http://www.google.com?foo=1&bar=2"'
Nvm, turns out putting %26 works instead of ampersand.

Use %26 as &.. its the html escape code for &.
<a href='mailto:info#example.com?subject=Testing&body=http://www.google.com?foo=1%26bar=2'>Send mail</a>

Related

Pass Variable into location.href

I have a dynamic Url, and in my html i want to do something like this:
<a onclick="location.href='myVariable';"><span>Click here</span></a>
This spells out the word 'myVariable' in the URL instead of using the value of my variable. I have also tried:
<a onclick="location.href='{{myVariable}}';"><span>Click here</span></a>
I used the brackets since my application is using angularJS, but that doesn't work either.
Is there a way to do this in HTML? Rather than using an onclick javascription function?
Any help is appreciated!
Try this:
<a ng-href="{{myVariable}}"><span>Click here</span></a>
You don't have to use an onclick event when clicking on an "a"-tag. The tag is used to hyperlink to another page. Use this:
<a href='myVariable'><span>Click here</span></a>
And if you´re changing the url, perhaps you should add a slash before 'myVariable':
<a href='/myVariable'><span>Click here</span></a>

link is not opening in new tab using <a href ></a>

this is a line of code that makes an item in mocel a url to external site
but this is opening same tab not in a new tab.
little help would be much appreciated
#item.hello
remove the comma before the target and you should have the same quotes (either single or double) for all parts of the line of code and alternate them when required (such as in the body of the href as opposed to the start / end).
<a href='#string.Format("url/{0}",item.hello)' target='_blank'>#item.hello</a>
You have use:
#item.hello
You mustn't put , but here:
#item.hello
Like you can see it work
link

Does browser interpret html tags which are inside input tag or not

I have updated it. let me make it more clear
<input type="text" value='<div>hello</div><strong>'/>good day
what I have got
input box having default value as <div>hello</div><strong> inside it and the text following the input good day does not inherit the strong tag it looks normal font size and it is not interpreted by browser and this is what i want.
http://jsfiddle.net/UrGpC/3/ This is what i really want to be but does it work in all browsers ?
The browser does not treat the html tags which are inside the input value as the normal flow of html tags from my experiment or does it interpret them ?
You should try and see, it doesn't interpret it as an element, it get rendered as plain text, try loading jQuery and change it thru it:
$('#test').html("ok");
http://jsfiddle.net/nd87/UrGpC/
Next time you should Test it and explain what you have tried
Well you can try this:
<input type="text" value="<div>hello</div><strong>" />
PD: You forgot to close the value atributte :P
EDIT:
It's works for me, is so strange... Anyway if it doesn't work you can try & lt; and & gt; method.
<div>hello</div>
As Wesley Murch said. ;)
I tried to do this recently, but gave up. According to this: http://www.w3.org/TR/html4/interact/forms.html#adef-value-INPUT, input value is CDATA, which seems to mean basically only ordinary characters can be included. http://en.wikipedia.org/wiki/CDATA

Is it valid to escape html in a href attribute?

Assuming I have the following link:
<a href='http://google.com/bla'>http://google.com/bla</a>
Is this one also valid?
<a href='http://google.com/bla'>http://google.com/bla</a>
It works in Firefox, but I'm not sure if this is standardized behavior. I hope the question isn't super dumb!
Yes, it is perfectly valid to do that. In fact, the ampersand (&) character must be escaped into & in order to be valid HTML, even inside the href attribute (and all attributes for that matter).

Why is MVC 4 Razor escaping ampersand when using HTML.Raw in a title attribute

We recently upgraded to MVC 4 and now we are having titles in our links not display correctly. The problem is before HTML.Raw would not escape & in our title attributes, but now it does. Below is my sample code:
<a title="#Html.Raw("Shoe Size 6½-8")">Test</a>
Which produces the following markup:
<a title="Shoe Size 6&#189;-8">Test</a>
The only solution I found so far was to put the entire anchor into a string and then HTML.Raw that string.
Why is Html.Raw escaping ampersand in anchor tag in ASP.NET MVC 4?.
This is a very ugly solution and I am hoping there is a better alternative.
While it is only a small step less ugly workaround, you can simply #Html.Raw the full attribute name and value.
<a #Html.Raw("title=\"Show Size 6½-8\"")>Test</a>
Results in:
<a title="Show Size 6½-8">Test</a>
If you can't do the workaround listed above, I have a patched base-class you could try injecting via web.config. Check it out at https://gist.github.com/4036121