Solved

JavaScript to open a link in an iframe and PopUp Blockers

Posted on 2004-08-23
5
407 Views
Last Modified: 2008-02-01
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
Comment
Question by:danths
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 300 total points
ID: 11876204
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
 
LVL 15

Expert Comment

by:Thogek
ID: 11876916
Is there a reason why target="_blank" is currently being used?  (Is the opening of a new window necessary?)
0
 
LVL 3

Expert Comment

by:Ayesha_K
ID: 11879871
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
 
LVL 6

Author Comment

by:danths
ID: 11881166
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
 
LVL 15

Assisted Solution

by:Thogek
Thogek earned 200 total points
ID: 11883676
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question