问题
I want to call the window.open
method in JavaScript code on an iPad. When I call that method, it works fine. Now I want to return a value from the HTML page which is opened by the window.load
method. It returns values in other browsers, but it is not returning a value in the iPad Safari browser.
回答1:
Unlike most browsers, the tabs in Safari on the iPad can't communicate with each other. You should rethink your interface to avoid window.open if you can and instead use an HTML-based dialog that opens a popup within your page. Something like jQuery-UI dialog or similar code.
EDIT: jQuery-UI Dialog example
To use the dialog you'll need an element in your HTML that provides an area for the hidden dialog markup:
<div id="dialog">This could have a preset message or you can override it.</div>
Then you will call this dialog using jQuery like this:
$('#dialog').dialog();
If you want to change the contents of the dialog first do:
$('#dialog').html('<p>Some html content.</p>');
$('#dialog').dialog();
See the documentation here for more details.
来源:https://stackoverflow.com/questions/11827158/ipad-safari-browser-does-not-support-the-window-open-javascript-method