I require the ability to open a new window
window.open(url,'_blank');
Then run a javascript script such as
window.open(url,'_blank').ready("javascript in here");
But I don't know how to do it, is there a way that I can do this?
The description is short but I think that's all that needs to be said
To open a new tab, we have to use _blank in the second parameter of the window. open() method. The return value of window. open() is a reference to the newly created window or tab or null if it failed.
Answer: Use the JavaScript window. location Propertylocation property to make a page redirect, you don't need any jQuery for this. If you want to redirect the user from one page to another automatically, you can use the syntax window. location. replace("page_url") .
How do I open a link in a new tab but stay on the same page in Google Chrome? You can simply open a new tab and stay on the same page by: Right clicking the link that you want to open in a new tab. Then select, “Open link in new tab”
In short you cannot do what you are asking. The new window is sandboxed. It can only run javascript referenced within its own html file.
One possible solution that might get you what you need would be to use postMessage. Even so in order to do this the receiving page needs to be listening to potential messages. https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
An alternative would be to include a query param in the url and parse that param out client side in the new window and take action based on the value of the param.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With