pop up window issue in mobile safari
i am working on web application which needs to open new browser window for some purpose.i am using JavaScript window.open() method for this.once child window is created using this method i am using window.focus() method to navigate between parent and child window.this works fine on all desktop and android browser.
code:
<a href="javascript:void(0);" onclick="openWin('url')">
to open window:
function openWin(url){
myWindow = window.open(url,"myWindow");
myWindow.opener = window;
myWindow.focus();
}
to switch back to parent from child
window.opener.focus();
switch to child again
myWindow.focus();
now the problem is when i use it on mobile safari (ipod touch) it shows alert message "This site is attempting to open a pop up window" with options "Allow" and "block". when i click on allow,it opens new window but navigation using window.focus is not working.i think its because safari browser takes it as a pop up window and not full browser window and so it can not return browser object while creation(myWindow).
in this same application i am using same code on click on button and it works on ipod very well w开发者_如何学Pythonith no such alert message, but its not working with anchor tag.
can anyone point me what i should do to make it work,thanks in advance. Anil.
You may review these GIT issues - 6617, 5663, 6864
You could try to handle this popup as an Alert. You may try to use following code snippet -
// SWITCH TO ALERT
Alert alert_obj = webDriver.switchTo().alert();
// ACCPET IT
alertObj.accept();
精彩评论