Forum Moderators: open
http://www.example.com/&print=true
How can I get the new window to open to the address below?
http://www.example.com/?&print=true
[edited by: Fotiman at 6:26 pm (utc) on Nov. 13, 2008]
[edit reason] Examplified the URLs [/edit]
function extendSearch(addon) {
if (window.location.href.indexof('?') == -1) {
// Append ?
addon = '?' + addon;
}
else {
// Append &
addon = '&' + addon;
}
window.open(window.location.href + addon, '_blank');
}
Or the more condensed form:
function extendSearch(addon) {
window.open(window.location.href + (window.location.href.indexOf('?') == -1 ? '?' : '&') + addon, '_blank');
}
And make sure your links don't include the &.
[edited by: Fotiman at 6:37 pm (utc) on Nov. 13, 2008]