iPad issue with Javascript window.open?

I have some javascript that opens separate windows in certain instances.

Case A looks like this:
if (ac == "b") {
                  dest = "asbuilts/" + cid + ".gif";
                  window.open(dest,"asbuilt","width=800,height=1100,scrollbars=yes,menubar=yes");
                  ac = "";
                  return false;
            }
Case B looks like this:
function get_cat() {
            if (document.st.pcat.value != "") {
                  pcats = document.st.pcat.value;
                  dest = "sel_parts.php?wo=<? print $woid; ?>&ptype=" + pcats;
                  window.open(dest, "woparts","width=800,height=1100,scrollbars=yes,menubar=yes");      
            }
      }
In Case B, the function get_cat is referenced in the html like this:

<select name="pcat" class="pt10" onChange="get_cat();">

In case A, it works on the iPad.

In Case B, it works on my (Gen 1) iPad, it does not work on the customer iPad (probably NOT Gen 1).

Is there any known issue regarding this on iPads?
Richard KortsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
Are you saying Case A does work on the customers iPad?
Must be the change event on the Select - try using onblur instead
0
Richard KortsAuthor Commented:
To Gary,

You mean "onblur" instead of onchange"? I seem to recall something odd about onchange on a select.

But, on the other hand, according to my Javascript "bible" says it does just what i am expecting.

Doesn't onblur mean when focus goes away from that element?

Thanks,

Richard
0
GaryCommented:
Yes and Yes
Googling and it does seem to be a problem (and it rings a bell with me as well)
Also seems to be a problem if the select is a multiple select

http://www.experts-exchange.com/Q_28247436.html
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Richard KortsAuthor Commented:
Since I know that Javascript is case sensitive & I was using  onChange="get_cat();" with a capital C, I changed it to lower case & ask them to try again.

The customer reports this:

"Alan tried the pop up again on his personal iPad as well as three different iPads at the apple store and each time he gets an alert that a pop up is trying to open, but it never does and freezes out the application."

The select in this instance is NOT a multiple.

My guess is that either my iPad is too old & they have changed Safari (I don't think I ever updated, maybe I should), or there is a setting regarding popups in "Settings".
0
GaryCommented:
Do you know what version of iOS they are on?
There was bugs with alerts /confirms in v7, which while you are opening a popup you are triggering the alert.
0
Richard KortsAuthor Commented:
Gary,

No, but they say they tried it at an Apple store with "several" iPads, which I assume are the latest IOS, etc.

Coming back to "onblur" do you think that would work? My gut feel is it's something about onchange.

Thanks
0
GaryCommented:
If they are getting the alert then it means the onchange is firing and the freezing when the alert comes up indicates a bug with iOS

Did you try the hack in the link above?
0
Richard KortsAuthor Commented:
Gary,

I looked at that link. I don't understand how that applies??

I want to open a window, etc. I'm missing something.

function SetCard(sel) {
   setTimeout(function() { alert('SetCard called successfully.');},10);
    document.getElementById("msg").innerHTML=sel.value + ":" + sel.options[sel.selectedIndex].text;
}
0
GaryCommented:
function SetCard(sel) {
    setTimeout(function() { 
     document.getElementById("msg").innerHTML=sel.value + ":" + sel.options[sel.selectedIndex].text;
},10);
 } 

Open in new window

0
Richard KortsAuthor Commented:
Gary,

I have no clue what that does & I don't see how it applies in my case.
0
GaryCommented:
It's a workaround, did you try it, it delays the window.open  by a fraction of a second.
0
Richard KortsAuthor Commented:
You mean lines 2 - 4 of that function would be the first lines in my onchange = function?

Thanks
0
GaryCommented:
Replace your function with this

function get_cat() {
	setTimeout(function() { 
	if (document.st.pcat.value != "") {
		pcats = document.st.pcat.value;
		dest = "sel_parts.php?wo=<? print $woid; ?>&ptype=" + pcats;
		window.open(dest, "woparts","width=800,height=1100,scrollbars=yes,menubar=yes");      
	}
	},100);
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard KortsAuthor Commented:
OK, I did that, it works fine on my Win 7 PC & it works on my iPad (with minor annoyance).

It asks to allow pop-up or not. I answered OK & it opened the window.

In Settings, Safari, I have Block Pop-ups set to off. Why the message?

I asked the customer to try it on his iPad.

Thanks

Richard
0
Richard KortsAuthor Commented:
Customer just emailed me: "Works like a Champ".

Richard
0
GaryCommented:
I don't know.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.