File path not working in window.open(). | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

File path not working in window.open().

I have a file path which when I use in href attribute of anchor tag, it is working but when I use in window.open(), it is not working can anyone give solution. It is urgent!!!

21st Jan 2022, 3:46 AM
Harsh
Harsh - avatar
3 Answers
+ 3
Just doing this should work - window.open(url, '_blank').focus();
22nd Jan 2022, 6:37 AM
Ankita Kumari
Ankita Kumari - avatar
+ 2
// init urls let newUrl = 'http://example.com'; let currentUrl = window.location.href; // open window with url of current page, you will be automatically moved // by browser to a new opened tab. It will look like your page is reloaded // and you will stay on same page but with new page opened window.open(currentUrl , '_blank'); // on your current tab will be opened new url location.href = newUrl;
9th Feb 2022, 4:04 PM
Ankita Kumari
Ankita Kumari - avatar
0
Ankita Kumari If the url is https://www.google.com/ then, can you give me example ?
23rd Jan 2022, 6:46 AM
Harsh
Harsh - avatar