Using javascript/jquery, I want to open a new tab. I have this code:
window.open("../scripts/map.php", '_blank');
which does it, but I also want to attach a huge json string as a parameter. I don't want to attach it to the url. Is there a way to make a jquery ajax call, and have the returned html string, set in the new tab?
Thanks.
open() method is used to open a new browser window or a new tab depending on the browser setting and the parameter values. Approach: To open a new tab, we have to use _blank in the second parameter of the window. open() method.
Open a new tab . Or, use a keyboard shortcut: Windows & Linux: Ctrl + t. Mac: ⌘ + t.
The short answer is: just add a target="_blank" attribute to your links (anchor tags). Now when your visitors click that link, it will open in a new window or tab (depending on which web browser they are using and how they configured that browser).
You need to use the _blank value in the target attribute to open the linked URL in a new tab or window. If you want to open URL with JavaScript, the open() method of Window interface is the best option. The JavaScript window. open() method opens a new browser window.
You could define a (possibly hidden) form element, give it the action of the url you want to post to, the method "post", and a target of "_blank", set the json to one of its input fields, the submit the form with jquery using $(form).submit (). You can even use jquery to create and remove the form at runtime.
The target attribute for forms works the same as for hyperlinks.
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