Reputation: 23
I have the following code below in a javascript file and need to have the link that is being generated open in a new window.
if (currentSearchType === 'extSearch') {
extSearchSearchValue = extSearchSearchInput.val();
window.location.href = replaceByObject(global.uhg.data['general'].body.extSearchSearchUrl, {
q: extSearchSearchValue
});
Normally with javascript I believe you'd use a window.open type of function, but not sure how to incorporate that with this type of code.
Upvotes: 2
Views: 299
Reputation: 4963
However you do it, opening a new browser window with javascript will most probably be blocked by popup blockers, so perhaps you should rethink your approach to the user himself clicking a regular link, then you can use target="...".
Upvotes: 1
Reputation: 82483
Just use a var to hold the URL and then pass it to window.open()
...
if (currentSearchType === 'extSearch') {
extSearchSearchValue = extSearchSearchInput.val();
var url = replaceByObject(global.uhg.data['general'].body.extSearchSearchUrl, {
q: extSearchSearchValue
});
window.open(url, 'searchWindow');
}
Upvotes: 0