if (msg.d.Address != null) {
var $a = $('<a id="courseDirections">');
$a.attr('href', 'http://maps.google.com/maps?q=' + msg.d.Address + " " + msg.d.City + " " + msg.d.State + ", " + msg.d.Zip)
.attr('target', '_blank')
.html("Click to get directions...");
$('#courseDirections').html($a);
}
This code works in all browsers but IE.
Simply trying to add a link to a div?
Golgotha:
if (msg.d.Address != null) {
var $a = $('<a id="courseDirections">');
$a.attr('href', 'http://maps.google.com/maps?q=' + msg.d.Address + " " + msg.d.City + " " + msg.d.State + ", " + msg.d.Zip)
.attr('target', '_blank')
.html("Click to get directions...");
$('#courseDirections').html($a);
}
Try it this way instead:
if (msg.d.Address != null) {
$('<a>', {
id: 'courseDirections',
href: 'http://maps.google.com/maps?q=' + msg.d.Address + " " + msg.d.City + " " + msg.d.State + ", " + msg.d.Zip,
text: 'Click to get directions...',
click: function () {
window.open(this.href);
}
}).appendTo('#courseDirections');
...
}
@Paul , hey that code works good, except in IE it opens the href in _self AND _blank?
I just did window.open(this.href); return false; and we’re good.
Thank you. The _blank target is not valid when using strict HTML4. it was deprecated from due to scripting being more appropriate for that type of behaviour.