I don't know how to solve this issue, I've trying reading many post but no one answer to it.
I need to open a new window with a page already coded (inside the same domain) and add some content.
The problem is that if I use OpenWindow.write()
the page is not loaded yet or it overrides everything and only the code added through write appears.
var OpenWindow = window.open('mypage.html','_blank','width=335,height=330,resizable=1'); OpenWindow.document.write(output);
output
is the code I need to append.
I need it to work at least on Firefox, IE and GC.
Thanks in advance. It is not a problem if I need to use JQuery.
Using Right Click. Right click on the link on your current window. Choose Open in New Window . The page will open in a new window.
To open a new window, use a keyboard shortcut: Windows & Linux: Ctrl + n. Mac: ⌘ + n.
When You want to open new tab/window (depends on Your browser configuration defaults):
output = 'Hello, World!'; window.open().document.write(output);
When output is an Object
and You want get JSON, for example (also can generate any type of document, even image encoded in Base64)
output = ({a:1,b:'2'}); window.open('data:application/json;' + (window.btoa?'base64,'+btoa(JSON.stringify(output)):JSON.stringify(output)));
Update
Google Chrome (60.0.3112.90) block this code:
Not allowed to navigate top frame to data URL: data:application/json;base64,eyJhIjoxLCJiIjoiMiJ9
When You want to append some data to existing page
output = '<h1>Hello, World!</h1>'; window.open('output.html').document.body.innerHTML += output; output = 'Hello, World!'; window.open('about:blank').document.body.innerText += output;
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