Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

JavaScript to open a link in an iframe and PopUp Blockers

Hello,
  I need to open a link in an iframe to do some server validation and redirectthe user to a different location in a new window.
So on click of the submit button, I do some javascript validation and then within the function
document.DataFrame1.location = "action_server_validate.asp?ml_num=" +  d.ml_num.value ;

The action_server_validate generates code to submit a form to an external website with arguments target="_blank"
which is blocked by pop-up blockers.
What are the workarounds...

One way I presume is to substitute the above statement to

window.open("action_server_validate.asp?ml_num=" + d.ml_num.value) ;


anything else...

Thx!
0
danths
Asked:
danths
2 Solutions
 
ZvonkoSystems architectCommented:
Instead to target the respnse to _blank you could target it to a previously opened popup.
The target name is the second parameter in window.open() call.
Like this:

window.open("", "newWin");
document.DataFrame1.location = "action_server_validate.asp?ml_num=" +  d.ml_num.value ;

Now when your action_server_validate.asp set the targe="newWin" will the popup be populated with the response.



 
0
 
ThogekCommented:
Is there a reason why target="_blank" is currently being used?  (Is the opening of a new window necessary?)
0
 
Ayesha_KCommented:
not sure if i'm understanding the problem correctly or not ... but if your browser is not allowing pop-up windows then it wouldn't allow to open you a new one no matter what the name of the window will be ... i mean your page WILL open a new window ... but the user's browser wouldn't let it get displayed ... this is a user's browser setting ... and you can set it  open pop-ups for your own testing purpose but u can't restrict user to view a pop-up even if he has blocked pop-ups.
0
 
danthsAuthor Commented:
Yes, it is necessary to open the url in a new window.


Ayesha:- I did some basic reading on how these pop-up blockers work, and the difference is that they allow a new window if the user intentionally does an action like click a button or url etc.

Zvonko:- Isn't the net affect of your suggestion the same as
window.open("action_server_validate.asp?ml_num=" + d.ml_num.value) ;
0
 
ThogekCommented:
Depending on the popup-blocker softwares involved, most should allow a popup window to appear if the context of the attempt to open the window is a mouse-click event.  I wouldn't guarantee that they all work that way, but by now, I believe that most of 'em do.

> The action_server_validate generates code to submit a form to an external
> website with arguments target="_blank" which is blocked by pop-up blockers.

Can we get a clearer idea as to exactly what action_server_validate is doing?
It *sounds* like action_server_validate is generating an HTML page with an HTML form with target="_blank", and auto-submitting that form via embedded JavaScript (either inline or in an onload handler).  (I'm guessing based on what you've said above; please correct me if this is incorrect.)  If this is so, then the context of the attempt to open the window is a page's onload, *not* a click event, and popup blockers *will* block that.

Have you tried, as you suggested, replacing the initial document.DataFrame1.location assignation with a call to window.open?  (In such a case, the window.open call would be within a click/submit event, and should be allowed by most popup-blockers.)  If so, does that work?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now